File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes where do i place html,class files etc? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "where do i place html,class files etc?" Watch "where do i place html,class files etc?" New topic
Author

where do i place html,class files etc?

krishnammal iyer
Greenhorn

Joined: Aug 27, 2004
Posts: 7
hi all,
iam trying to learn jsp using Tomcat. iam using the book head first servlets & jsp!
i have been following the instructions in the book on creating packages/folders and placing them as follows:

html files:
tomcat\webapps\Beer-v1\form.html
servlet class files:
tomcat\webapps\Beer-v1\WEB_INF\classes\com\example\web\BeerSelect.class
when i tried to run the html file i got the error "404 the requested resource /Beer-v1/form.html" does not exist. i did some search on the internet and found that the html files need to be placed in the ROOT directry under webapps. i did that and the html file worked.
next i tried to invoke the servlet but the error "requested resource /BeerSelect.do does not exist. i chkd the internet again and iam getting so many conflicting answers on where the classes files should be placed!
has anyone placed similar problems? and where should i place all the files?
thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
This could be just a typo on your part, but the directory is named "WEB-INF", not "WEB_INF". Inside WEB-INF you need a web.xml file where your servlets are mapped. Lastly, "BeerSelect.do" seems to indicate that you're using Struts, which is probably much more advanced than where you're at right now (unless BeerSelect.do is mapped to the BeerSelect.class which is a servlet; but that would need to be declared in web.xml).


Ping & DNS - my free Android networking tools app
krishnammal iyer
Greenhorn

Joined: Aug 27, 2004
Posts: 7
hi Ulf Dittmer ,
yes the WEB-INF is a typo! srry!
and yes BeerSelect.do is mapped to BeerSelect class file in the web.xml!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
I think your class file is placed correctly. Why don't you post the <servlet> and <servlet-mapping> parts of your web.xml file; that could help point to the problem.
krishnammal iyer
Greenhorn

Joined: Aug 27, 2004
Posts: 7
this is the web.xml file!

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi=schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>
 
GeeCON Prague 2014
 
subject: where do i place html,class files etc?