Problems with JSP

I'm running Tomcat 5.0 and it all works fine, I'm mostly doing servlets and it's all cool. Now I would like to move to .jsp pages but I can't get the damn thing to work and I don't know why...

Do I have to create a new webapp for my .jsp files or add some xml info or what?

I have a simple example:

 <HTML>
 <BODY>
  Hello!  The time is now <%= new java.util.Date() %>
 </BODY>
 </HTML>

When I call it from my browser I get errors like this:

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)

Now, why am I getting this errors?, do I have to import something like a regular .java file or what?

Thank in advance and please provide some usefull tips...

;)
LVL 9
stefanaichholzerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

petmagdyCommented:
Yes make sure that u defined in ur Path Env. variable:

${Java_home}\bin

also that:
${Java_home}\lib\tools.jar

is in ur classpath
0
stefanaichholzerAuthor Commented:
How, where do I do that? I can't seem to find somthing to do that in Tomcat

Thanx
0
petmagdyCommented:
if ur JDK is installed for example at c:\jdk14.2 the
1- make sure that ur OS PATH enviroment variable part of it is ....;c:\jdk14\bin;.....

also open ur tomcat startup batch file and make sure that part of the classpath is c:\jdk14.2\lib\tools.jar
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

kiranhkCommented:
you need to add these in your startup.bat after this line -> rem Guess CATALINA_HOME if not defined

set JAVA_HOME=D:\jdk1.5.0 (Change to your java installation path)
set CATALINA_HOME=D:\jakarta-tomcat-5.5.2(Change to your tomcat installation path)

then as petmagdy suggests add tools.jar into classpath

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lhankinsCommented:
You should be able to get by with <just> defining the JAVA_HOME environment variable to point to your local JDK installation.   The tomcat startup scripts will implicitly add %JAVA_HOME%/bin to the path where neccessary.

One easy way to do this is to open up startup.bat and define JAVA_HOME at the top of it (other apps may need different versions of the JDK).

0
stefanaichholzerAuthor Commented:
kiranhk and friends,

OK, I added following lines to the startup.bat file:

  set JAVA_HOME=C:\Global\Java\jdk1.4\
  set CATALINA_HOME=C:\Global\Apache\Tomcat 5.0\

Reloaded the server and still the same errores, and I don't know how to add the tools.jar into the classpath.

Errors I get:

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)
0
stefanaichholzerAuthor Commented:
How does the /jsp-examples/ folder run the .jsp files?, I went through the folder and there is some .xml defining all the .jsp files that are in the folder, do I have to do something like that?, because if I have to I give up JSP :(

Thanx
0
kiranhkCommented:
No you dont have to put any xml file.
Maybe there is problem with the JAVA_HOME you would have set.
can you check out catalina.bat and see if this line exists

call "%CATALINA_HOME%\bin\setclasspath.bat"

and if it is there can you also check out in setclasspath.bat whether it is having this line

set CLASSPATH=%JAVA_HOME%\lib\tools.jar


Then make sure your your Java installation is correct.

If any of those line are not there can you add them and check
0
stefanaichholzerAuthor Commented:
Ok, I guess that's it, I added the lines kirank gave me, but still the damn thing wasn't working. I was using the Tomcat monitor to restart the server and that was not doing it, then I started the server from the DOS prompt, using the startup.bat and then it worked just fine. I can now run all my .jsp files.

Still I would like to know why did I have to restart the server using the startup.bat and why wouldn't it work using the Tomcat monitor??

Thanx to all you guys...

 --> http://stefan.cuencaweb.com/thanx.htm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.