• Post Reply Bookmark Topic Watch Topic
  • New Topic

Apache Tomcat Errors???  RSS feed

 
Julia Irving
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I recently installed Apache Tomcat 3.1 b/c I am using a book that had it on a disk. I was able to run the sample JSPs and even a JSP that finds the sine of an array of angles. But when I try to run a JSP that I wrote to open a directory (C:\testdir), I get a bunch of errors that are don't make any sense to me. If you can, please give me an idea of what they mean or where I can look to get more comprehensible errors. Listed below are the errors and the code. Thanks so much for any help!
<ERRORS>
Error: 500
Location: /myJSPs/Hour2/pamtest.jsp
Internal Servlet Error:
org.apache.jasper.compiler.ParseException: C:\Hour2\pamtest.jsp(5,16) Attribute value should be quoted
at org.apache.jasper.compiler.JspReader.parseToken(JspReader.java, Compiled Code)
at org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:461)
at org.apache.jasper.compiler.JspReader.parseTagAttributes(JspReader.java, Compiled Code)
at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java, Compiled Code)
at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled Code)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java, Compiled Code)
at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java, Compiled Code)
at java.lang.Thread.run(Thread.java:479)
</ERRORS>

<CODE>
<HTML>
<HEAD> <TITLE>LISTING FILES OF A DIRECTORY</TITLE> </HEAD>
<BODY>
<P> SHARED FILES:
<%@ page import=�java.util.Vector*�%>
<%!
Vector v = new Vector();
Vector getAllFiles(java.io.File location) //takes in dir location
{
java.io.File [] list = location.listFiles(); //places all files of
//dir into list
for (int i=0; i < list.length; i++)
{
v.addElement(list[i]); //if entry is a file, adds element to v
if ((list[i]).isDirectory()) //if entry is a dir, recursively
{ //calls getAllFiles
getAllFiles(list[i]);
}
}

return v;//returns list of all files as vector, v
} %>
<%
java.io.File tempdirec = new java.io.File("C:\\testdir");
Vector vec = getAllFiles(tempdirec);
//results from getAllFiles will be
for (int i=0; i<vec.size(); i++) //returned into vec
{
String filename = (String)vec.elementAt(i);//prints filename %>
<P> <%= filename %>
<% } %>
</BODY>
</HTML>
</CODE>
Thanks again for any help or guidance!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Julia,
Your import statement is invalid. It should be:

Also, the UBB code tags use square, not angle brackets.
hth,
bear
P.S. Also, not Tomcat-specific
[ August 06, 2003: Message edited by: Bear Bibeault ]
 
Julia Irving
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I changed the import but am still getting similar errors:
Error: 500
Location: /myJSPs/Hour2/pamtest.jsp
Internal Servlet Error:
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:386)
at Hour_00032._0002fHour_00032_0002fpamtest_0002ejsppamtest_jsp_0._jspService(_0002fHour_00032_0002fpamtest_0002ejsppamtest_jsp_0.java, Compiled Code)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:479)
Root cause:
java.lang.ClassCastException
at Hour_00032._0002fHour_00032_0002fpamtest_0002ejsppamtest_jsp_0._jspService(_0002fHour_00032_0002fpamtest_0002ejsppamtest_jsp_0.java, Compiled Code)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:479)
Is there a way to get these errors in a better form. All I have to go from are these and my small jsp file. I would appreciate any suggestions! Thanks in advance!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first suggestion would be to factor as much Java out of the JSP page and into a controller servlet and/or beans as possible. It's better structure, and a heck of a lot easier to debug.
As you can see from your error output, you are getting a class cast exception somewhere in your JSP. Since the java for the JSP wasn't written by you (it was generated on your behalf by the servlet container), it's harder to use a stack trace from a JSP than from your own code.
But if you insist on putting heaps of Java in the JSPs, your best bet is to take a peek at the Java files generated for them when things go awry.
Btw, what version of Tomcat are you running? Unless I'm wrong it's an older one since I think that the newer versions give better stack traces for JSP-generated errors, which make it easier to spot errors in the JSP pages.
hth,
bear
 
Julia Irving
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,
You're right I should try using JAVA beans. It will make debugging much easier. I am running Tomcat 3.1, b/c I have been using a book that follows it. Now, that I got it up and running, I will download a newer version.
Thanks again for your help!
Julia
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks to me like you're building a Vector of java.io.File objects, then trying to read them back out of the vector as Strings. That's not going to work, and it will cause a ClassCastException.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!