[opencms-dev] Establish a session with openCMS

Florian Hopf hopf at synyx.de
Tue Jan 9 11:08:09 CET 2007


Hi,

Jaisy Ann Cheriyan wrote:
>
> import org.opencms.file.*;
>
> import org.opencms.db.*;
>
> import org.opencms.main.*;
>
>  
>
>  
>
> public Class FetchData {
>
>             public static void main(String[] args){
>
>                         try{
>
>                         String loggedUser;
>
>                         CmsObject cmsObj =
> OpenCms.initCmsObject(CmsDefaultUsers.getUserGuest());
>
>                         loggedUser = cmsObj.loginUser("Admin",
> "adminuser");
>
>                         System.out.println("Login Successful for " +
> loggedUser);
>
>  
>
>                         CmsFile fetchFile = new CmsFile(CmsResource
> resource)
>
>                         byteContents = fetchFile.getContents();
>
>  
>
>  
>
>  
>
>  
>
>  
>
>                         }
>
>                         catch(Exception exp){
>
>                                     System.out.println("Exception!!");
>
>                         }
>
>             }
>
> }
>
>  
>
>  
>
Be aware that this won't work because you are in a different VM than
OpenCms. Either your class is in opencms-context (in your servlet
container) or you start it by yourself using OpenCmsShell.

Kind regards
Flo

-- 
/**
 * Florian Hopf
 * Synyx GmbH & Co. KG
 * phone  +49(0)721 6624866
 * eMail  hopf at synyx.de
 * www    http://www.synyx.de
 * irc    irc://irc.synyx.de
 */




More information about the opencms-dev mailing list