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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Tomcat server webpage error" Watch "Tomcat server webpage error" New topic
Author

Tomcat server webpage error

Mufleeh Sadique
Greenhorn

Joined: Aug 21, 2011
Posts: 7
Hi,

I am new to tomcat server as well as to this forum. Hope you guys could help me figuring out my problem.

I've installed tomcat stack in my local pc to work on the coding given my course. Server is working properly but I get some error messages for some sort of coding.

For example when I run the below code,




The page gives an out put as below,


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:

An error occurred at line: 13 in the jsp file: /helloworld.jsp
The type Date is ambiguous
10: <body>
11:
12: <%!
13: Date theDate = new Date(); // Variable declaration
14: Date getDate() // Method declaration
15: {
16: System.out.println("In getDate() method" );


An error occurred at line: 13 in the jsp file: /helloworld.jsp
The type Date is ambiguous
10: <body>
11:
12: <%!
13: Date theDate = new Date(); // Variable declaration
14: Date getDate() // Method declaration
15: {
16: System.out.println("In getDate() method" );


An error occurred at line: 14 in the jsp file: /helloworld.jsp
The type Date is ambiguous
11:
12: <%!
13: Date theDate = new Date(); // Variable declaration
14: Date getDate() // Method declaration
15: {
16: System.out.println("In getDate() method" );
17: return theDate;


An error occurred at line: 17 in the jsp file: /helloworld.jsp
theDate cannot be resolved to a variable
14: Date getDate() // Method declaration
15: {
16: System.out.println("In getDate() method" );
17: return theDate;
18: }
19: %>
20:


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


Can anyone help me fixing this?
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

This isn't a Tomcat issue, it's just a compiler error.

Replace



with



Your servlet compiler is able to find more than one possible match for Date in its class library.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Scriptlets in a JSP in 2011?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mufleeh Sadique
Greenhorn

Joined: Aug 21, 2011
Posts: 7
Guy deLyonesse wrote:This isn't a Tomcat issue, it's just a compiler error.

Replace



with



Your servlet compiler is able to find more than one possible match for Date in its class library.


Hi,

Thanks for your response, I think there exist another issue. It gives the below exception now.


exception

org.apache.jasper.JasperException: /date.jsp (line: 11, column: 3) Unterminated <%! tag
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
org.apache.jasper.compiler.Parser.parseDeclaration(Parser.java:628)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1429)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

From looking at your code in the first post, it doesn't look like you're closing your JSP tag.

Mufleeh Sadique
Greenhorn

Joined: Aug 21, 2011
Posts: 7
Guy deLyonesse wrote:From looking at your code in the first post, it doesn't look like you're closing your JSP tag.



Yes, you were correct. I haven't added the closing tag. But hard luck now it gives another error for the below code block.



Error is,

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 16 in the jsp file: /date.jsp
The type Date is ambiguous
13:
14: <%!
15: java.util.Date theDate = new java.util.Date(); // Variable declaration
16: Date getDate() // Method declaration
17: {
18: System.out.println( "In getDate() method" );
19: return theDate;

Here I have imported "java.util.*" and when I tried replacing it with import="java.util.Date", nothing is displayed, it becomes blank.




Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

Then in the method declaration specify the return type as a java.util.Date.

Actually, these questions aren't Tomcat specific and should probably go in the JSP forum
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Really they are just basic Java questions, but at least one of them involved fumbling the JSP tags so I'll move it to the JSP forum.
Niju Thomas
Greenhorn

Joined: Jul 29, 2011
Posts: 13
Just try this
change '<!' to '<%'.
 
 
subject: Tomcat server webpage error