• Post Reply Bookmark Topic Watch Topic
  • New Topic

error in running the jsp

 
Anant Chandra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to jsp and servlets.

I am trying to run the jsp called counter.jsp
<html>
<body>
<%@ page language="java" %>
<%! int count =0; %>
<% count++; %>
Welcome! You are visitor number
<%= count ; %>

</body>
</html>

I have stored the counter.jsp at the following location
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT

When I run counter.jsp using my tomcat 5.0(already started) by following stat. http://localhost:8080/counter.jsp , I am getting the 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
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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


Can any body help me ??? What to do do correct the error???.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anant,
There are two things related to your issue, that I want to point out:
1)
Perhaps JAVA_HOME does not point to the JDK
This statement I have picked from the root cause of your error log, please check you JAVA_HOME environment variable to ensure it is reflecting the right path.
2)
<%= count; %>

This statement should give you a translation error, The reason is that expressions do not have semicolon because ultimately it will be translated to out.print(count; ) ; and this is not valid java statement. Therefore remove the semicolon.
Also if JAVA_HOME variable is fine then instead of putting this JSP file under ROOT folder try putting it under any other application folder under webapps folder and see.
I have tried your code on my system and it works absolutely fine for me.

[ May 07, 2007: Message edited by: Rancy Chadha ]

[ May 07, 2007: Message edited by: Rancy Chadha ]
[ May 07, 2007: Message edited by: Rancy Chadha ]
 
Anant Chandra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot, Rancy.

Actually your both the statements were right.
Now I can run the code
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think using the semicolon for the expression results in this message. Your original jsp page got translated but when it is compiling, it gives you the error message.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!