Questions about JSP programming 2007-01-15 - By Xuekun Hu
Back Thanks Rashmi, Zack, and Pid Sorry it's my fault. <%@ include file="request.getParameter("f") %> should not be compiled successfully. I fisrt tested <jsp:include page../>, it works, TOMCAT translated and generated the .java and .class file, then I just modified the same jsp file with <%@ ... %>, TOMCAT compiled it failed. TOMCAT deleted the .java file, but kept the .class. When I load tested the URL again, Some requests will get 500 error, while most are still get the right response!
Now I understood the two include difference. Thanks again.
Thx, Xuekun
On 1/15/07, Pid <p@(protected)> wrote: > Firstly, all directives of the following form are executed at compile time: > > <%@ ... %> > > This means that URL request parameters are not available (yet) to the > JSP. If the OP was using an include file directive containing the > string 'request.getParameter("f")' it is unlikely that it ever worked as > expected. > > The JSTL approach below is likely to work - though I can't think of a > good or safe reason for allowing JSPs to load file system paths. > (if you're on a unix-like system, try loading '/etc/passwd') > > > > Secondly, <jsp:include ... > operates at *request time* and may > therefore be more pertinent to the case here. OP should google for 'JSP > directive tutorials', the top result was enlightening when I checked. > > > > Lastly, the OP should report on which tool (if any) he was using to load > test the URL. It may simply be the case (assuming the above error is > corrected) that the excessive load caused the machine to run out of > memory. > > The normal approach is to examine the logs to determine the source of > the 500 error, the list will likely provide more advice on receipt of > this information. > > > p > > > > Rashmi Rubdi wrote: > > Zack, > > > > I don't think it's the include directive alone causing a memory error. I'm guessing that there might be a lot of processes in his application running on Tomcat, eventually causing an out of memory error or may be the system does not have minimum required memory to run Tomcat. > > > > With Tomcat 5.5, and about 2GB RAM I'm not getting an OutOfMemory error while running 3 applications simultaneously on Tomcat, when I tried his example of include directives, I got the error on the screen and it was logged in Tomcat's logs as well. > > > > I ran my test as follows: http://practice:8080/p/test2/test2.jsp?f=page .html , and test2.jsp had <%@ include file="request.getParameter("f")" %> (which I believe won't work) > > > > Here's parts of the error, if it helps him: > > > > HTTP Status 500 - > > type Exception report > > message > > description The server encountered an internal error () that prevented it from fulfilling this request. > > exception > > org.apache.jasper.JasperException : Unable to load class for JSP > > org.apache.jasper.JspCompilationContext (JspCompilationContext.java :598) > > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper .java:137) > > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper.java :305) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:314) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:264) > > javax.servlet.http.HttpServlet (HttpServlet.java:802) > > root cause > > java.lang.ClassNotFoundException : org.apache.jsp.p.test2.test2_jsp > > java.net.URLClassLoader $1.run(URLClassLoader.java:200) > > java.security.AccessController (Native Method) > > java.net.URLClassLoader (URLClassLoader.java:188) > > org.apache.jasper.servlet.JasperLoader (JasperLoader.java:133) > > org.apache.jasper.servlet.JasperLoader (JasperLoader.java:65) > > org.apache.jasper.JspCompilationContext (JspCompilationContext.java :596) > > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper .java:137) > > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper.java :305) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:314) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:264) > > javax.servlet.http.HttpServlet (HttpServlet.java:802) > > > > > > Also, if he sets up JSTL1.1 correctly, the following will also work: > > > > <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> > > <c:import url="${param.f}"/> > > > > Where param.f , is the equivalent of request.getParameter("f") > > > > -Rashmi > > > > > > Rashmi, > > > > I'm curious as to why his second approach causes the memory error that > > he gets, would you have any insight as to why it's happening? I've > > checked out the docs and they don't indicate anything about the way the > > include directive uses memory. I'm thinking we might actually have a > > bug to report. > > > > Zack > > > > > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ __ ______ > > The fish are biting. > > Get more visitors on your site using Yahoo! Search Marketing. > > http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php > > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > > To start a new topic, e-mail: users@(protected) > > To unsubscribe, e-mail: users-unsubscribe@(protected) > > For additional commands, e-mail: users-help@(protected) > > > > > > > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > To start a new topic, e-mail: users@(protected) > To unsubscribe, e-mail: users-unsubscribe@(protected) > For additional commands, e-mail: users-help@(protected) > >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To start a new topic, e-mail: users@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
|
|