Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where do i place html,class files etc?

 
krishnammal iyer
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
krishnammal iyer
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic