This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark ""MVC" controller servlet" Watch ""MVC" controller servlet" New topic
Author

"MVC" controller servlet

malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Hi, I am new to Servlets and JSP
I have recently read about MVC model.
In the following example:



If the request is to "searchperson" the contrller calls the "searchPerson" method, and then this method instantiation the DAO class
and then redirect to "showperson.jsp"

I want to know what if I have more userActions. Then how does controller servlet should work?
Can I use
if(userAction.equal("...."))
{
//call some method or redirect to JSP
}

again again for ever request.

Thanks.
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

malik ge wrote:

I want to know what if I have more userActions. Then how does controller servlet should work?


I dont understand what you mean by more actions


Ashwin Sridhar
SCJP | SCWCD | OCA
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
By "usreAction" I mean " String userAction = request.getParameter("action");" the action here is passed from JSP page

In above example the userAction is "searchperson"

The JSP:
<html>
<body>
<h3> Search Person </h3>
<form name="search" action="controller" />

<table border= '1'>
<tr>
<td> <h4> Name </h4> </td>
<td> <input type="text" name="name" </td>
</tr>

<tr>
<td colspan="2" align="center">
<input type="submit" name="action" value="searchperson">
<input type="reset" value="Clear">
</td>
</tr>

</table>
</form>
<body>
</html>
 
Consider Paul's rocket mass heater.
 
subject: "MVC" controller servlet
 
Similar Threads
how to call JSP from Servlet
not able to insert values in ms access database
problem in servlet to jsp
Front controller that doesn't stink
GET Method Working But POST is not