jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes  First Jsp - HTTP 404/Not Found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark " First Jsp - HTTP 404/Not Found" Watch " First Jsp - HTTP 404/Not Found" New topic
Author

First Jsp - HTTP 404/Not Found

Jim Panagiotopoulos
Greenhorn

Joined: Aug 05, 2001
Posts: 11
hi all,
I have displayed the tomcat default page but when i try my own jsp i get a HTTP 404 - File not found in my
Internet Explorer. i would greatly appreciate any insight.
Thanks,
Jim
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
where did u place ur jsp page in??? better place it in Web directory!! im sure u will have a directory called Web in ur tomcat server , just place ur jsp page there and it query, it should work!!


SCJP, SCWD <br />A farmer learns more from a bad harvest than a good one.
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Which version of TOMCAT do you have installed?
I am an advocate of placing the JSPs in one directory under the root, which has the name (or facsimile) related to the application name.
I don't know how many beginners with TOMCAT know this, but you can have your JSPs wherever you like. You don't need to place them In a "special" place.
You do have to tell TOMCAT that you want to do this and also where the document root for the application is going to be.
In the server.xml file, you can state:
<!-- My Application Context -->
<Context path="/myapplication" docBase="C:\myapp" debug="0"/>
I forget the exact meaning of "debug" but you get the picture.
Then your application root would be at c:\myapp.
Another thing, while in this subject, is that you can define the servlet path name to your servlets using the <servlet-mapping> element in web.xml.
There is nothing sacred about the /servlet/ part of the path.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Put it in your webapps directory - actually, you should stick it in a subidirectory in webapps (i.e. webapps/yourapp).
Also, you'll probably need to make an additional context entry in tomcat.conf
Open up tomcat.conf and look for the line like this:
<b>ApJServMount /examples /root</b>
and add your own directory to it so it looks like
<b>ApJServMount /examples /root /yourapp</b>
If you just installed Tomcat and haven't changed anything else it should be as simple as this. (of course there is a 90% chance I am forgetting something but Im sure somebody else will help out if I have)
Good luck
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
All the configurations and stuff may be still too confusing for you. I usually do this before i start messing with web.xml or server.xml.
In your Tomcat\webapps directory create folder and call it, for example, myproject. Place your test.jsp page in that folder,
restart Tomcat. Open up your browser and type http://localhost:8080/myproject/test.jsp
That is all you shoul do.
Jim Panagiotopoulos
Greenhorn

Joined: Aug 05, 2001
Posts: 11
Hi,
First off thanks for the prompt responses!I reinstalled Tomcat in order to get a fresh start.I think i've tried to do all those things and its still not working.Here's the response in the dos screen:
Ctx():404 R( +/ExJSP/MyFirstJSP.jsp + null) JSP file not found.
I'm pretty sure that because i'm trying a little of everyone's suggestions im getting thrown off with the directories and editing variables and stuff.Well I've been at it for over 10 hours now and i want to get this right! lol! If any one can give me a step by step installation guide i would appreciate it.
Thanks Vivek,Tony,B.J.,and Mocca for your input.I've learned alot already!
Jim
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Oh, I think maybe you should ignore what I said about Tomcat.conf - I apologize if I confused you. I am using Apache with Tomcat which has involved Tomcat.conf but you shouldn't worry about it.
Anyway, Mocca Az and Vivek probably have the best advice here - keep it simple.
Does your out of the box Tomcat install work at all? Can you run any of the examples? Please tell me the directory on your machine that MyFirstJSP.jsp is located in, and also exactly what URL you are entering in your browser.
Hang in there.

[This message has been edited by BJ Grau (edited September 02, 2001).]
[This message has been edited by BJ Grau (edited September 02, 2001).]
[This message has been edited by BJ Grau (edited September 02, 2001).]
[This message has been edited by BJ Grau (edited September 02, 2001).]
Jim Panagiotopoulos
Greenhorn

Joined: Aug 05, 2001
Posts: 11
Hi BJ,
No apologies necessary . You guys have been a big help.
The file is in c:\tomcat\ExJSP\MyFirstJSP.jsp.
I can see the default page and run its examples.Do i have to set an environmental variable that i perhaps have overlooked?
My autoexec.bat looks like this:
rem - By Windows 98 Network - C:\WINDOWS\net start
SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.2.1\BIN;%PATH%
I know that i have to set HOME_PATH=C\JDK1.2.1.
I'm not so sure if i'm supposed to change the classpath in tomcat.bat or in autoexec.bat though. lol!What do you think?

Thanks ,
Jim
Tomcat Marathoner
Jim Panagiotopoulos
Greenhorn

Joined: Aug 05, 2001
Posts: 11
Thanks for to Vivek,Tony,B.J.,and Mocca for your input ! I finally installed tomcat! aaahhhhhhh..........zzzzzzzzzzzzzzzzzzzzz
mocca az
Ranch Hand

Joined: Mar 07, 2001
Posts: 93
Jim,
You didn't follow instructions that i posted. If you want to keep existing path to your .jsp files then you must follow instructions posted by sheriff Tony, therefore you must edit server.xml found in C:\Tomcat\conf directory.
If you want keep it simple then you must follow instructions posted by me earlier, which means that your .jsp pages must live in C:\Tomcat\webapps\ExJSP\MyFirstJSP.jsp.
If you can run default examples than your CLASSPATH, JAVA_HOME & TOMCAT_HOME are set correctly.
follow this steps
1. Create folder called ExJSP in C:\Tomcat\webapps
= C:\Tomcat\webapps\ExJSP
2. Put MyFirstJSP.jsp in this folder
= C:\Tomcat\webapps\ExJSP\MyFirstJSP.jsp
3. Start Tomcat or restart it if its running already so the changes take affect.
4. Open up your browser and type http://localhost:8080/ExJSP/MyFirstJSP.jsp
This is it.
The error message you are getting at the moment means that Tomcat can't find directory ExJSP therefore MyFirstJSP.jsp can't be found as well. Reason for this is because your folder/file does not live in C:\Tomcat\webapps and the place where it lives "c:\tomcat\ExJSP\MyFirstJSP.jsp" is not configured in server.xml.
If you follow the steps i describe above, you can't miss it.
Hopefully after you get some sleep you'll clear your head up a bit an stay with me on this one, OK...
 
wood burning stoves
 
subject: First Jsp - HTTP 404/Not Found
 
Similar Threads
Problem in opening .html and .jsp extension files.
Servlet Error Regarding
"10.4.5 404 " error in Netscape 6.2.1, but not in IE
Webutilities
404 not found