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 now always forwarding to same page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet now always forwarding to same page" Watch "Servlet now always forwarding to same page" New topic
Author

Servlet now always forwarding to same page

Tom Joiner
Ranch Hand

Joined: Sep 19, 2006
Posts: 47
I created the following servlet:



The problem is it always goes to "Overview.html" and never goes to Test.html. I have tried recompiling the servlet, rerunning it, and it still always goes to the place I directed it on the first compile.

Why?


Another related question.. where do people normally stick their jsp pages for handling web pages? I have been sticking them in

\project\build\web\folder\name.jsp

But now it looks like perhaps I should be placing them in

\project\WEB-INF\folder\name.jsp

which is correct?
[ November 15, 2006: Message edited by: Tom Joiner ]

SCJP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Your code tags are malformed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by Tom Joiner:
The problem is it always goes to "Overview.html" and never goes to Test.html. I have tried recompiling the servlet, rerunning it, and it still always goes to the place I directed it on the first compile.


Have you restarted the web app?

nother related question.. where do people normally stick their jsp pages for handling web pages? I have been sticking them in

\project\build\web\folder\name.jsp

But now it looks like perhaps I should be placing them in

\project\WEB-INF\folder\name.jsp

which is correct?[/QB]


Either can be correct. If your JSPs are to be directly addressable they must reside outside of the WEB-INF folder. If they are not to be addressable, and only reachable through their servlet controllers, then placing them under WEB-INF is appropriate.
Tom Joiner
Ranch Hand

Joined: Sep 19, 2006
Posts: 47
I am not sure actually how to "restart the web app". I closed the browser, and then reran the application in the NetBeans IDE using "Run Main Project".

I managed to fix the problem by renaming the original servlet. Then, I added in a new link in the web.xml so that the web server could see this new servlet, and the new servlet is working properly. I am not sure what was going wrong but thanks for the ideas.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Renaming the servlet to fix this is not a good solution. When a servlet is changed, the web app needs to be restarted. You should learn how to run a web app outside of an IDE. Otherwise, you are hobbled.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet now always forwarding to same page