wood burning stoves 2.0*
The moose likes JSP and the fly likes Very  simple JSP with Scriplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Very  simple JSP with Scriplet" Watch "Very  simple JSP with Scriplet" New topic

Very simple JSP with Scriplet

Raja Shekar

Joined: May 20, 2008
Posts: 3
I have a very simple JPS with 4 lines of code. While launching the page am getting the below exception. Please help in resolve this
Server :Tomcat 6.0.16
OS: Windows Vista.
JDK :Java6

1 <%
2 response.sendRedirect("first.jsp");
3 return;
4 %>


May 21, 2008 12:21:41 AM org.apache.jasper.compiler.Compiler generateJava
FINE: Generated /C:/apache-tomcat-6.0.16/work/Catalina/localhost/weblog//org/apache/jsp\index_jsp.java total=19 ge
May 21, 2008 12:21:41 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 9 in the jsp file: /index.jsp
Unreachable code
6: <%
7: response.sendRedirect("first.jsp");
8: return;
9: %>
10: </body>
11: </html>

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:316)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:129)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60785

JSPs get translated into servlets. You have an unconditional return in your JSP that is followed by something -- in this case HTML markup.

The servlet code that is generated to emit the HTML markup is after the return, and therefore is unreachable. This is not legal in Java.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raja Shekar

Joined: May 20, 2008
Posts: 3
Thanks that worked.
Sorry for confusing with huphens' (-----)
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Its always better to look at the generated servlet class in order to troubleshoot.
It is sorta covered in the JavaRanch Style Guide.
subject: Very simple JSP with Scriplet
Similar Threads
Exception in PhaseListener RESTORE_VIEW 1 afterPhase
Tomcat 6.0.18 Setup Issues - JasperException: Unable to compile class for JSP
Unable to read TLD "META-INF/tld/tiles-jsp.tld" from JAR file
problem in relative path in jsp page
Unable to read TLD "META-INF/tld/tiles-jsp.tld" from JAR file