The Artima Developer Community
Sponsored Link

Java Answers Forum
simple JSP program, error 500 file not found problem

7 replies on 1 page. Most recent reply: Sep 2, 2002 12:18 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 7 replies on 1 page
Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

simple JSP program, error 500 file not found problem Posted: Aug 29, 2002 11:36 AM
Reply to this message Reply
Advertisement
Below is a simple JSP file,
the file is located at D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\Hour8

<HTML><HEAD>&l t;TITLE>Overriding toString() Method</TITLE></HEAD><BODY>
<%@ page import="Hour8.OverridingToString"%>
<%! OverridingToString ots1 = new OverridingToString();
OverridingToString ots2 = new OverridingToString("New Message");
%>
<UL>
<LI>ots1 = <%=ots1%>
<LI>ots2 = <%=ots2%>
</UL>
</BODY></HEAD>
Below is simple Java file.
The file has been complied so thus both the source file and .class file is located at
D:\tomcat\jakarta-tomcat-3.3.1\webapps\ROOT\WEB-INF\classes\Hour8

Here is the source code:
public class OverridingToString{
String message = "Default Message";
public OverridingToString(){}
public OverridingToString(String msg){message = msg;}
public String toString(){ return message; }
}

Please note previous all inclusive JSP programs worked, that is java code and JSP code were all in one file.
Now I have a simple JSP and a Java file, this does not work.

I have started tomcat and accessing the jsp file at browser address:
http://localhost:8080/myJSPs/Hour8/overridingToString.jsp

Error: 500
Location: /myJSPs/Hour8/overridingToString.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\Hour8\overridingToString_1.j ava:6: Class Hour8.OverridingToString not found in import.
import Hour8.OverridingToString;
^
1 error

at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
a t org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Inte rceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:5 16)
at java.lang.Thread.run(Thread.java:484)


Ana

Posts: 12
Nickname: anika
Registered: Aug, 2002

Re: simple JSP program, error 500 file not found problem Posted: Aug 30, 2002 4:10 AM
Reply to this message Reply
Hi northfield, you may try locating your .class file in another directory, since it seems that it is not found.
If you have a web application called "myJSPs", and two different directories:

D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Hour8
and
D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\WEB-INF\classes\Hour8

Place your jsp in the first one, your .class in the second one, import the .class just as previously done and try:
http://127.0.0.1:8080/myJSPs/jsp/Hour8/overridingToString.jsp

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: simple JSP program, error 500 file not found problem Posted: Aug 30, 2002 2:53 PM
Reply to this message Reply
Hey,
I noted that you have the class file located at:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\ROOT\WEB-INF\classes\Hour8
That would work if your class was a member of the Hour8 package.

I think you have to either:

move the OverridingToString.class to the directory one up from Hour8 to
D:\tomcat\jakarta-tomcat-3.3.1\webapps\ROOT\WEB-INF\classes\

or

add the package command to your java source and recompile:
*******

package Hour8
public class OverridingToString{
String message = "Default Message";
public OverridingToString(){}
public OverridingToString(String msg){message = msg;}
public String toString(){ return message; }
}

Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

Re: simple JSP program, error 500 file not found problem Posted: Aug 31, 2002 5:36 PM
Reply to this message Reply
it doesn't work.

Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

Re: simple JSP program, error 500 file not found problem Posted: Aug 31, 2002 7:24 PM
Reply to this message Reply
My question is why does it seem to be so esotric in dividing JSP and class files seperately?

I am at the end my tether and really frustrated.
As I have tried with every known combinationss of folder combination. Of Webapps, ROOT, WEB-INF, classes etc ...


Here is all the information again:

My JSP File located at: D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Hour8

<HTML><HEAD&g t;<TITLE>Overriding toString() Method</TITLE></HEAD><BODY>
<%@ page import="OverridingToString"%>
<%! OverridingToString ots1 = new OverridingToString();
OverridingToString ots2 = new OverridingToString("New Message");
%>
<UL>
<LI>ots1 = <%=ots1%>
<LI>ots2 = <%=ots2%>
</UL>
</BODY></HEAD>

The class file is at D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\WEB-INF\classes\Hour8:

package Hour8;
public class OverridingToString{
String message = "Default Message";
public OverridingToString(){}
public OverridingToString(String msg){message = msg;}
public String toString(){ return message; }
}

I start the simple web Application:

http://localhost:8080/myJSPs/jsp/Hour8/overridingToString.jsp

Error: 500
Location: /myJSPs/jsp/Hour8/overridingToString.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\Hour8\overridingToString _1.java:6: Class OverridingToString not found in import.
import OverridingToString;
^
1 error

at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Inte rceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:5 16)
at java.lang.Thread.run(Thread.java:484)


Please try to help?
Some one must be working on similar stuff with JSP???????@???>????@?< <>

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: simple JSP program, error 500 file not found problem Posted: Sep 1, 2002 2:12 PM
Reply to this message Reply
Hey, your server.xml file is supposed to have a context entry in it such as:

<Context path="/"
docBase="webapps/myJSPs"
debug="0"
reloadable="true"
trusted="false" >
</Context>

Your server.xml file is under the conf folder.
You should read up on a Tomcat how to tutorial. There are dozens available on the web. Perhaps searching google or www.ixquick.com would get you going.

For such a basic jsp and java bean example, you could try putting your jsp files in the default ROOT directory, and the class file in the ROOT/WEB-INF/classes/Hour8 folder and skip the server.xml entry above.

I had the same troubles when I first tried to get a jsp example like yours going. Yeah, it was frustrating. The documentation did not seem to make any sense.

Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

Re: simple JSP program, error 500 file not found problem Posted: Sep 1, 2002 3:33 PM
Reply to this message Reply
Charles Bell,

I have it working now. My book does not tell you were to put the class files (probably expects this as prior knowledge) so it is probably not very good. However I do like the topics.

>Hey, your server.xml file is supposed to have a context entry in it.
I have read about context and server.xml before. Question, when they mention the "context" is this like a path to your web files like jsp, servlets etc?

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: simple JSP program, error 500 file not found problem Posted: Sep 2, 2002 12:18 PM
Reply to this message Reply
Hey, congratulations on getting your jsps going!

As best as I understand it, contexts are like web applications that have a folder under the tomcat webapps folder.

The server.xml file designates where and how to treat these different contexts.

I have a context setup in my Tomcat server.xml file
as follows:
<Context path="/"
docBase="webapps/htdocs"
debug="0"
reloadable="true"
trusted="false" >
</Context>

I put my web and jsp pages in the docBase or "webapps/htdocs" folder
and my class files in the "webapps/htdocs/WEB-INF" folder

When I start my tomcat server running on my pc, I put in the following url in my web browser to see the root index html web page:
http://127.0.0.1/index.html and from there link to subfolders where my jsp files are located. Classes in the "webapps/htdocs/WEB-INF" folder are accessible from jsps.

If a have classes that are part of a package, then a folder structure that reflects the package name relative to webapps/htdocs/WEB-INF must be setup.

The java.sun web site has a Java Web Services tutorial at:
http://java.sun.com/webservices/docs/1.0/tutorial/index.html

They have a whole section on Getting Started With Tomcat at:

http://java.sun.com/webservices/docs/1.0/tutorial/doc/GettingStarted.html

There is a Marty Hall tutorial for Tomcat 4 at:
http://www.moreservlets.com/Using-Tomcat-4.html

I am no expert on all this jsp stuff, but I have managed to get a nice web application working on the internet, nothing as fancy as this site.

Flat View: This topic has 7 replies on 1 page
Topic: email address in applet Previous Topic   Next Topic Topic: Help with calling a file from Java file(GUI)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use