<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<META content="MSHTML 6.00.2800.1264" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2><STRONG>Hi,</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2><STRONG></STRONG></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>I am developing Intranet site with OpenCms.
I have a problem with createResource method. First JSP is
:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><%</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Create a JSP action
element<BR>CmsJspActionElement cms = new CmsJspActionElement(pageContext,
request, response);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Create a string of requested file<BR>String
filename = cms.getRequestContext().getUri();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Get CmsObject<BR>CmsObject cmsObject
=cms.getCmsObject();<BR>String userName =
request.getParameter("OPENCMSUSERNAME");<BR>String password =
request.getParameter("OPENCMSPASSWORD");<BR>boolean logout = false;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>if (request.getParameter("OPENCMSUSERNAME") ==
null)
{<BR> %><BR> <table><BR> <form
name="login" method="post" action="<%=
cms.link("ImportPDF.jsp")%>"><BR> <tr
align="left"><td
colspan="2"><br><p><b>Prijava:</b></p></td></tr><BR> <tr><BR> <td><p>Username:
</p></td><BR> <td><p><input
type="text" name="OPENCMSUSERNAME" size="15"
maxlength="64"></p></td><BR> </tr><BR> <tr><BR> <td><p>Password:
</p></td><BR> <td><p><input
type="password" size="15" maxlength="32"
name="OPENCMSPASSWORD"></p></td><BR> </tr><BR> <tr
align="center"><td colspan="2"><input type="submit"
value="Prijava"></td></tr><BR> </form><BR> </table><BR> <%<BR>}
else {<BR> out.println("Pocinjem prijavu na OpenCMS !!");<BR> try
{<BR> cmsObject.loginUser(userName,password);<BR> out.println("Welcome
to OpenCMS! \n Korisnik: " + userName +
"<br>");<BR> %><BR> <form
name="webhouse" action="<%= cms.link("/intranet/jsp/obrada1.jsp")%>"
method="post" enctype="multipart/form-data"><BR>
Naslov:<INPUT size=80
name="NavText"><br><BR> Virtualni fajl
sistem:<INPUT size=80 name="Path"><br><BR>
Ključne
reči:<BR><BR>
<TEXTAREA name="Keywords" rows=3 cols=25 size="30"></TEXTAREA>
<BR> Opis
strane:<BR><BR>
<TEXTAREA name="Description" rows=3
cols=25></TEXTAREA><br><BR>
<INPUT type=file size=60
name="Page"><br><BR>
<INPUT type=radio value="V1" name="Format"> HTML
<BR>
<INPUT type=radio value="V2" name="Format">
PDF<br><BR>
<INPUT type=submit value=Pošalji name=Send> <INPUT
type=reset value=Poništi name=Cancle><BR>
</form><BR> <!-- enctype="multipart/form-data"
--><BR> <%<BR> <BR> //nastavak<BR> <BR> }
catch(CmsException e) {<BR> System.out.println(new
java.util.Date() + " OpenCMS INFO: Neuspesno ulogovan korisnik " +
userName);<BR> out.println("<h2>Neuspešna
prijava na sistem, molimo pokušajte
ponovo</h2>");<BR> }//end catch<BR>}<BR>%></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>As you can see it's very simple and I use
it for log in and showing a form for uploading PDF files. After that I use
another JSP for processing data. Code is:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><%<BR>// Create a JSP action
element<BR>CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext,
request, response);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Create a string of requested file<BR>String
filename = cmsJsp.getRequestContext().getUri();<BR>CmsObject cms =
cmsJsp.getCmsObject();<BR>String format =
cmsJsp.getRequestContext().getRequest().getParameter("Format");<BR>out.println("Format:
" + format);<BR>String pathVFS = "";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Enumeration files =
cms.getRequestContext().getRequest().getFileNames();<BR>out.println("Prosao
enumeration!!");<BR>while (files.hasMoreElements()) {<BR> out.println("Usao
u while!!");<BR> String fileName = (String)
files.nextElement();<BR> fileName =
fileName.toUpperCase();<BR> System.out.println("Ime: " +
fileName);<BR> if (fileName.endsWith(".PDF") && fileName !=
"unknown") {<BR> System.out.println("Usao i if
(PDF)");<BR> byte[] filecontent = (byte[])
cms.getRequestContext().getRequest().getFile(fileName);<BR> //Prijava
admin user-a<BR> try
{<BR> cms.loginUser("Admin","opencms");<BR> cms.getRequestContext().setCurrentProject(3);<BR> System.out.println("Uspesno
logovanje Admin-a");<BR> Hashtable props = new
Hashtable();<BR> //props.put("Title",cmsJsp.getRequestContext().getRequest().getParameter("Page"));<BR> props.put("Description",cmsJsp.getRequestContext().getRequest().getParameter("Description"));<BR> props.put("Keywords",cmsJsp.getRequestContext().getRequest().getParameter("Keywords"));<BR> props.put("NavText",cmsJsp.getRequestContext().getRequest().getParameter("NavText"));<BR> System.out.println("Setovani
Properties za file-ove");<BR> CmsResource cmsres =
null;<BR> System.out.println("Kreiranje PDF file-a u
CMS-u!!");<BR> pathVFS =
cms.getRequestContext().getRequest().getParameter("Path");<BR> try{<BR> //cms.lockResource(pathVFS);<BR> cms.getRequestContext().setCurrentProject(3);//temp
project ID<BR> System.out.println("Na
putanji: " + pathVFS);<BR> cmsres =
cms.createResource(pathVFS, fileName, "binary", props,
filecontent);<BR> System.out.println("PDF
file je uspesno kreiran u CMS-u !!");
<BR> }catch(CmsException
e){<BR> System.out.println("Neuspesno
kreiranje !!!");<BR> out.println("Neuspesno
kreiranje
PDF!!!");<BR> e.printStackTrace();<BR> }<BR> }
catch(CmsException
e){<BR> System.out.println("Neuspesno logovanje
!!!");<BR> } <BR> } <BR>} <BR>%></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>VFS path is OK. I've got this error:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>javax.servlet.ServletException: Resource loader
error in file '/intranet/jsp/obrada1.jsp'</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Root
cause:<BR>org.apache.jasper.JasperException<BR> at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)<BR> at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)<BR> at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)<BR> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)<BR> at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)<BR>......</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Tomcat Log file:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><!--StartFragment --> <PRE>2004-01-26 16:01:15 ApplicationDispatcher[/opencms] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.opencms.file.mySql.CmsDbAccess.createFile(CmsDbAccess.java:352)
at com.opencms.file.genericSql.CmsResourceBroker.createFile(CmsResourceBroker.java:1789)
at com.opencms.file.CmsObject.doCreateFile(CmsObject.java:978)
at com.opencms.file.CmsResourceTypePlain.createResource(CmsResourceTypePlain.java:308)
at com.opencms.file.CmsObject.createResource(CmsObject.java:934)
at com.opencms.file.CmsObject.createResource(CmsObject.java:929)
at org.apache.jsp.WEB_002dINF.jsp.online.intranet.jsp.obrada1_jsp_jsp._jspService(obrada1_jsp_jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:742)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:542)
at com.opencms.flex.cache.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:158)
at com.opencms.flex.CmsJspLoader.service(CmsJspLoader.java:972)
at com.opencms.flex.cache.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:256)
at com.opencms.flex.CmsJspLoader.load(CmsJspLoader.java:577)
at com.opencms.flex.CmsJspLoader.initlaunch(CmsJspLoader.java:239)
at com.opencms.core.OpenCms.showResource(OpenCms.java:961)
at com.opencms.core.OpenCmsHttpServlet.doGet(OpenCmsHttpServlet.java:310)
at com.opencms.core.OpenCmsHttpServlet.doPost(OpenCmsHttpServlet.java:331)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:805)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:696)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:534)</PRE><PRE> </PRE><PRE>Please Help.</PRE><PRE> </PRE><PRE>Best regards, Ivan.</PRE></DIV></BODY></HTML>