File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes JSP page will not compile to Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP page will not compile to Servlet" Watch "JSP page will not compile to Servlet" New topic
Author

JSP page will not compile to Servlet

Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
I have a very simple servlet that forwards a response to a JSP. It's an example from 'Heads First Servlets and JSP'.

I have had this example working, then I created it again, and now I have a problem.

The servlet:


It is the call to view.forward that it causing an exception:

11-Nov-2005 23:40:18 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Ch3 Beer2 threw exception
java.lang.InstantiationError: org.apache.jasper.compiler.Compiler
at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:234).........

I know that the JSP page is being found, because if I provide an deliberately incorrect file name in request.getRequestDispatcher the server tells me that the file cannot be found. I also checked that the objects view, request and response were not null.

And the JSP is as simple as this:


So what could be the reason for this failure?

Kind regards,

Tony.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have you had any JSPs working?

Depending on your container, you may or may not need a full JDK in order to compile JSPs.
Sometimes the Tomcat installer will find an installation of Java on your machine other than the full JDK.
When this happens servlets will run but not JSPs.

Try hitting your JSP directly with a browser.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
I did, it works, so it isn't that.
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
Annoying thing is, I have had this working already. What I did in this case was just to try to recreate the book example again in a different directory.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What I did in this case was just to try to recreate the book example again in a different directory.


There's a clue.
What directory?

What is the directory structure of the two examples?
Start from the tomcat/webapps directory.
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
1) Deleted previous directory of code under Tomcat.

2) Created new directories.

3) Copied source from eclipse generated files to correct newly created directory.

4)Hit problems as described.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ben Souther:
What is the directory structure of the two examples?
Start from the tomcat/webapps directory.

[ November 11, 2005: Message edited by: Ben Souther ]
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
OK OK!

I'll check it out!

- Tony.
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 36
Actually, I found out that the cause of all my grief was the addition of the Tomcat 4.x patch for JSP debugging from Sysdeo. Probably doesn't help that I'm using Tomcat 5.5.

Anyway, removing these files fixes the problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Glad it's working for you.
Thanks for posting back.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP page will not compile to Servlet
 
Similar Threads
MVC + view.forward = loose coupling?
Head First Servlets and JSP simple exercise problem
Can't render JSP
Compiling result.jsp (page 89 HFSJ)
help needed with tomcat/requestDispatcher - example form HeadFirst servlets and jsp