File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes class compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "class compilation error" Watch "class compilation error" New topic
Author

class compilation error

Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 182

using bean i am running following jsp file

but it is giving following error


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 compile class for JSP:

An error occurred at line: 7 in the jsp file: /jsp/beandata.jsp
R_DESC cannot be resolved
4: <select Description="R_DESC">
5: <option value="Select">Select</option>
6: <%Iterator itr;%><% List data= (List)request.getAttribute("R_DESC");
7: for (itr=R_DESC.iterator(); itr.hasNext(); ){
8: %>
9: <option value="<%=itr.next()%>"></option>
10: <%}%>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
BeanInServlet.doPost(BeanInServlet.java:18)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
InfonetFilter.doFilter(InfonetFilter.java:43)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18
Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 182

the above program is running i have done following changes


but my problem is it is not print anything the dropdown.dropdown is blank
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

1) You're calling itr.next() twice inside the loop. You shouldn't do that. It moves the iterator forward to the next element. Best case you now get options with every even element (0, 2, 4, ...) as the option values and every odd element as the option labels. Worst case you will get a NoSuchelementException.

2) You should use a <c:forEach> tag for iterating through the List:
But I've already showed you how to do that in your other thread.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Megha Singhal
Ranch Hand

Joined: Feb 28, 2012
Posts: 182

Rob Spoor wrote:1) You're calling itr.next() twice inside the loop. You shouldn't do that. It moves the iterator forward to the next element. Best case you now get options with every even element (0, 2, 4, ...) as the option values and every odd element as the option labels. Worst case you will get a NoSuchelementException.

2) You should use a <c:forEach> tag for iterating through the List:
But I've already showed you how to do that in your other thread.


but now it is showing "${item}" in the dropdown.
i have used followin code in servlet

and also replace item in following code


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Then EL is disabled. Are you perhaps using servlet specification 2.3 inside your web.xml? If so, I suggest you consider switching to at least 2.4, but preferably 2.5 or even 3.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class compilation error
 
Similar Threads
Unable to compile class for JSP
http error?
problem calling servlet to build a list of data from a database and display a jsp page
I got http-500 error in servlet and jsp.how to find error?
Suddenly stopped working