Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error HTTP Status 500 -

 
ankittt agarwala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the following is encountered
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: 10 in the jsp file: /result.jsp
arraylist cannot be resolved to a type
7:
8: <%
9:
10: arraylist result= request.getAttribute("styles");
11: for(int i=0;i<=1;i++)
12: out.println("<br>try tea:"+result[i]);
13: %>


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:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.example.web.teaselect.doPost(teaselect.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

my servlet code is

and jsp code is





suggest the corrections...
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is case sensitive. I believe "arraylist" should be "ArrayList".
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ankittt agarwala wrote:suggest the corrections...

Correction 1: remove all Java code from the JSP. SCriptlets were fine 10 years ago. This is 2011. Time to step up to modern standards using the JSTL and EL.

Failing that, of course arraylist is a problem, This is Java, case counts! And even when you fix that, you will have further problems.

The bottom line is that Java code does not belong in a JSP!

[Edit:Ah, Tom snuck in before me!]
 
ankittt agarwala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this java class is used in servelet and looking at servlet code above can you tell the appropriate jsp code


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

Also, it is not clear to me what the servlet code has to do with your JSP issues.
 
ankittt agarwala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the servlet is passing an array to jsp
well thats all stuff is being used in a complete tomcat application
this is required
user clicks on a color in html page and a request is sent to servlet which uses java code for decision on tea brand and finally jsp is there to print the result to happy user and jsp page is not executing so suggest a valid jsp code which will work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that I can see your code, it makes little sense. Your servlet emits an HTML page and then also forwards to a JSP? What's the point of that? You can only return one response per request. Do you want to return the HTMl generated by the servlet, or do you want to return the HTML generated by the JSP? It makes no sense to do both.

And in the same way that a JSP shouldn't contain Java code, a servlet shouldn't emit HTML. Each the servlet and the JSP has their own job. The servlet should process data and prepare it for the JSP, which should only concentrate on creating the view (HTML page) and do so without embedded Java code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic