My JSP is submitting a form to servlet and servlet after processing the date and storing it into session forwards the request to the same JSP. The JSP onload checks that if value of particular variable is true, it closes itself. The JSP includes a javascript and .css file. The problem is when the request is forwarded to the JSP, i receieve following error in my tomcat console (Am using tomcat integrated in JBoss 3.2.5). But these errors are displayed when i first open this JSP from a link
2005-08-24 18:18:32,540 INFO [org.jboss.web.localhost.Engine] StandardContext[/workflow]Marking servlet org.apache.catalina.INVOKER.javascript.js as unavailable 2005-08-24 18:18:32,540 ERROR [org.jboss.web.localhost.Engine] StandardContext[/workflow]Error loading org.jboss.web.tomcat.tc5.WebCtxLoader$ENCLoader@4ae19a javascript.js java.lang.ClassNotFoundException: javascript.js at java.net.URLClassLoader$1.run(URLClassLoader.java:198) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:262) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:954) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687) at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:369) at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:536)
Any idea what could be the reason of the above exception?
Thanks, Kapil
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
Sorry for typing mistake. The error is not displayed when the JSP is loaded for the first time from a link
When he said "include" I assumed he meant using those mechanisms. It would be odd indeed to use a JSP include for such resources.
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
Yes, am using the standard HTML reference as Yuriy has mentioned. MY css and js files are in same directory as the JSP so I am refering them directly without giving the full path from the context. What i cant understand is why tomcat is treating .js and .css files as servlets?
David Ulicny
Ranch Hand
Joined: Aug 04, 2004
Posts: 724
posted
0
Could provide the code which do this exception?
SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
The JSP code snippet is following
The error comes after rediection to JSP page before it closes
David Ulicny
Ranch Hand
Joined: Aug 04, 2004
Posts: 724
posted
0
I'm not sure if it helps, but try it: in body tag should be OnLoad In function onLoading you are missing closing bracket.
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
I wrote <body onLod> because the site doesnot allow onload to be written while uploading code. I forgot to add closing bracked while pasting code. Actually, its a huge JSP thats why I added the relevant code. The error messages come even If I only use the given code snippet for JSP.
David Ulicny
Ranch Hand
Joined: Aug 04, 2004
Posts: 724
posted
0
Look at the java class which is generated from this JSP. There you should see what's happened whith javascript.js .
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
The generated code is following
David Ulicny
Ranch Hand
Joined: Aug 04, 2004
Posts: 724
posted
0
Everything looks fine. I'm sorry, I have no other ideas [ August 25, 2005: Message edited by: David Ulicny ]
3) What does your servlet configuration and mapping look like?
4) How is the form submitted? The action does not correspond to the class shown in your stack trace, and the form does not contain any fields; is that intentional? [ August 25, 2005: Message edited by: Ulf Dittmer ]
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
posted
0
The js file contains some utility functions common to my application. The screen is a popup window and its objective is to submit a form to a servlet and after successful completion, the form closes itself. The form is not submitted if I write window.close just after submitting, thats why i redirect the request back to same jsp which checks that the request is forwarded from a servlet and closes itself. I found that if i use sendRedirect instead of requestDispatcher.forward in servlet, there is no error in tomcat but that doesn't solve my purpose
Yuriy Zilbergleyt
Ranch Hand
Joined: Dec 13, 2004
Posts: 429
posted
0
The problem is that since you're forwarding and not redirecting, the browser thinks you are still in the servlet directory. For example, in the page showing you are submitting to
If that servlet forwards to a JSP, then any relative references in the JSP will be relative to the mapped location of the servlet, that is a link to "javascript.js" will actually be a link to "<context>/workflow/servlet/javascript.js". To link to the a javascript file inside the Initiator directory you'd have to have use "../../Initiator/javascript.js". Inother words you must link as though your JSP page was in the same location that the servlet was mapped to.
A better way would probably be to use request.getContextPath() to get the root of the application: