wood burning stoves 2.0*
The moose likes Servlets and the fly likes where to store the .htm files related to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to store the .htm files related to the servlet" Watch "where to store the .htm files related to the servlet" New topic
Author

where to store the .htm files related to the servlet

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
hi,
All the .html files related to a servlet are stored into which directory for the tomcat server?
thanks,
Trupti
Omar IRAQI
Ranch Hand

Joined: Jul 06, 2001
Posts: 54
Hi nigam,
When Apache receives a static request that concerns an html file, it does not forward it to Tomcat. Consequently, the html file is resolved with respect to Apache document root.
Now if you are using tomcat as a web server, the default document root is : $TOMCAT_HOME/webapps/ROOT/
Regards


Omar IRAQI Houssaini
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
trupti
Not to be smart about it but they go somewhere under the root of the web app. If you only have a few then just go ahead and put them in the root of the webapp if there are a lot of them you can create a directory structure under the root.
Then if you need to include or forward to one of them just use the path that starts at the context root, with a '/' and the container will be able to find it.
For example, you have an app named myApp in the webapps folder. In the myApp folder you could have your index page and another folder to hold html pages related to inventory control, it would look something like this:

Now in servlet1 to include one of the inventory pages, do this:
request.getRequestDispatcher("/inventory_pages/page1,html");
hope that helps


Dave
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
hi,
I have stored the .html file under install-dir/webapp/root/classes directory ,but when i try to access it as http://localhost:8080/servlet/ThreeParams.html i get an error message 404 that the file is not found.
thanks,
trupti
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
hi,
I have stored the .html file under install-dir/webapp/root/classes directory ,but when i try to access it as http://localhost:8080/servlet/ThreeParams.html i get an error message 404 that the file is not found.
thanks,
trupti
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
Trupti,
I wouldn't put anything but Servlets in the web-inf/classes directory. For one thing, there is some XML magic that happens in the background when you use /servlet/ that probably precludes regular files from being served from there.
Look at Dave's post again and put your HTML file in the root directory of your WebApp, then point your browser to:
http://localhost:8080/myWebApp/ThreeParams.html
GL,


Wait a minute, I'm trying to think of something clever to say...<p>Joel
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
joel,
I have put my htm file under
webapps/myhtmfiles/Threeparams.htm
now when i try to access it i get the 500 error saying that no context configured to process this request..
i Have put the servlet class files under webapps/root/WEB-INF/classes directory..

where am i going wrong?
thanks,
Trupti
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Trupti
If the file is in a subdirectory then you need to add the subdirectory to the path you're trying to access it on:
http://localhost:8080/myWebApp/myhtmfiles/ThreeParams.html
Also, have you done anything to the web.xml file? You dont need to change anything in that file to just serve HTML pages, unless you are rying to map them to different names or something like that. If that is your ultimate goal then try doing it the simple way first, just to make sure it works then you can add different things to it.
[ June 26, 2002: Message edited by: Dave Vick ]
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
hello,
I have a html file. named ThreeParamsForms.htm stored under c:\tomcat\webapps\myhtmfiles\*.htm directory.
The servlet class file threeparam.class file is stored under c:\tomcat\webapps\root\WEB-INF\classes\threeparam.class dirctory.
I have not registered this servlet under the web.xml file.
While accessing the htm file i access it through the following url..
http://localhost:8080/myhtmfiles/ThreeParamForms.htm
but i am getting http 404 error.
thanks,
Trupti
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Trupti
The files for the html need to be in a web application or you need to have a web.xml file to tell tomcat where to find them. Is the folder myhtmfiles a web application, doe sit have a WEB-INF directory? and a web.xml file?
If not then just typing the location of the file into the address line wont locate it as it has to be in an application.
Your servlet on the other hand is part of the root web app so it'll be fine. In the web.xml file under the root you can map to the html files and tell the container that they are in the other directory, but I pretty sure that only works for URI that would point to the root web app then the container would know that to go to the myhtmfiles directory to get them.
Try putting a WEB-INF folder in the myhtmfiles directory and a web.xml file, an empty one should even work. then restart tomcat so it recognizes it as a web application and it should work.
If these two are related (the html files and the servlet classes) then your best bet is to create a new web application under the tomcat/webapps and put all of the files in there. You'll need a WEB-INF directory and a web.xml file but then you should be all set.
Since this is more of tomcat problem you might be able to get better answers in the tomcat forum - I'm not a tomcat expert.
hope this helps
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
Dave,
Thanks a lot..
i was able to access the html file when i created a new folder with web-inf & web.xml folder & file in it respectively..as told by you..
trupti
sim sim
Ranch Hand

Joined: Jun 05, 2002
Posts: 55
Hi Trupti,
Put your myhtmfiles under webapp/ROOT directory. They should work them
c:\tomcat\webapps\ROOT\myhtmfiles\*.htm
I hope this works.
Sim Sim.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Trupti
Glad you got it to work!! Good luck with it and if you have more quetions just let us know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where to store the .htm files related to the servlet