File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP page will not compile to Servlet

 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did, it works, so it isn't that.
 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK OK!

I'll check it out!

- Tony.
 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad it's working for you.
Thanks for posting back.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic