Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class compilation error

 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic