GeeCON Prague 2014*
The moose likes Servlets and the fly likes one servlet works the other doesn't? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "one servlet works the other doesn Watch "one servlet works the other doesn New topic
Author

one servlet works the other doesn't?

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57


Ok I have one jsp it accesses servlet one like this:
<form name="form" method="post" action="test">
This works all just fine and dandy. In side servlet one my doPost method works just great!
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
checkInfo(request, response);
}
The checkInfo method does some dataBase work and takes me to my second jsp page.
Jsp page two accesses servlet two like this.
<form name="form" method="post" action="userControl">
When I click on the button to submit this page to the server I imediately get 404.
This is the doPost method of the second servlet.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
changeUser(request, response);
}
I am doing this in my dev environment, which is jbuilder5 it has tomCat built into it. Both of the servlets compile into class files.
If I access the 2nd servlet from a webBrowser it also says not found.
Any tips?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
404 implies that your second servlet can't be found which agrees with your attempt from the browser. Right off hand I guess you have not set the web.xml file up correctly.
Are these servlet classes in a package? Tomcat works much better if they are.
Bill
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Hi
Thanks for the reply. Yes these servlets are both in a package. They are in the same package and their classes are in the dir. I am using jbuilder5 which sets up the deployment descriptor for me as I create servlets just in the same way websphere does as u add a servlet to a webApplication.
Here is the deployment discriptor that was created by jbuilder for these servlets
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>loop.test</servlet-class>
</servlet>
<servlet>
<servlet-name>userControl</servlet-name>
<servlet-class>loop.userControl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>usercontrol</servlet-name>
<url-pattern>/usercontrol</url-pattern>
</servlet-mapping>
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Works great now!
 
GeeCON Prague 2014
 
subject: one servlet works the other doesn't?