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

Reusing Servlet.

ryan bohnert
Greenhorn

Joined: Feb 27, 2008
Posts: 19
I have an index page that uses a servlet called ApplServlet(gets a list of all applications) and forwards to the appl.jsp(displays all application names). Inside the appl.jsp, when I display the application names inside a form I allow the user to select buttons such as New (new applicaiton), View(view application details), Edit(edit details of the application), and Delete (delete application). All the buttons have name=actn. Once a button is selected it calls the same ApplServlet. I can see once the button is selected the value is passed in the url Appl?actn=New. The problem is when i try to read the URL variable using getParameter, it's always null.

First question, why is the parameter null?

Second question, is it okay for a servlet to forward to different JSP's? Ex. If actn=New, then forward to applNew.jsp, Else If actnView, then forward to applView.jsp, and so on.

thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5
First question, why is the parameter null?

Second question, is it okay for a servlet to forward to different JSP's? Ex. If actn=New, then forward to applNew.jsp, Else If actnView, then forward to applView.jsp, and so on.


1. most likely explanation - the name is not exactly matching - case? If this was my problem I would use the request method getParameterNames to see what names are being parsed out of the request.

2. OK? If it works, why not - sounds like a typical front controller.

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reusing Servlet.
 
Similar Threads
Swing GUI Interface Question
Someone Must Have an Example Like This!
IBM Exam 157 - Questions and Answers (Sample Exam)
How to find to which row is selected?
Inserting, Editing, deleting rows in JTable