• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat server webpage error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scriptlets in a JSP in 2011?
 
Mufleeh Sadique
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From looking at your code in the first post, it doesn't look like you're closing your JSP tag.

 
Mufleeh Sadique
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just try this
change '<!' to '<%'.
 
reply
    Bookmark Topic Watch Topic
  • New Topic