File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlet problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet problem" Watch "servlet problem" New topic
Author

servlet problem

Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi,
I installed Tomcat and Apache under win 95, set up the classpath as required. sample programs in dir \webappls\examples\servlets\ run OK. I compile my HTTPGetServlet.java and put the class file in \examples\Web-inf\classes\, the .html in \examples\servlets\
The .html file as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<!-- HTTPGETServlet.html -->
<HEAD>
<TITLE>Servlet HTTP GET Example</TITLE>
</HEAD>
<BODY>
<FORM ACTION = "http://127.0.0.1:8080/examples/Web-inf/classes/HTTPGetServlet"
METHOD = "GET">
<P>Click the button to have the servlet send an HTML document</P>
<INPUT TYPE = "submit" VALUE = "Get HTML document">
</FORM>
</BODY>
</HTML>
Please help,
Thanx,
Simon
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
sorry, i forgot to point out the problem.
the error given when i press the Button "Get HTTP document":
Not Found (404)
Original request: /examples/Web-inf/classes/HTTPGetServlet
Not found request: /examples/Web-inf/classes/HTTPGetServlet
Thanx,
Simon
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
"http://127.0.0.1:8080/examples/Web-inf/classes/HTTPGetServlet"
Is not the correct way to address the servlet. In fact, web servers are forbidden to directly serve any file from the WEB-INF directory. Instead, the server applies various rules to the raw URL to determine exactly what needs to be done.
"http://127.0.0.1:8080/examples/servlet/HTTPGetServlet"
should do the trick. Take a look at the example servlets and JSP provided with Tomcat to see how they are addressed. Study the web.xml file in the webapps/examples/WEB-INF directory.
Bill

------------------
author of:
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi, Bill,
I got it worked. But how does the server know the location of the class file?
Thanks,
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet problem