James West

Greenhorn
+ Follow
since Aug 13, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by James West

Cathy,

Shankar is correct.

In the below, replace "<" with a less than symbol, and ">" with a greater than symbol, and in "on Click" remove the space.

If you are confused, let me try to explain. After you have created your servlet and the web.xml mapping:

You can either set the action in the hidden field directly, or set it in a javascript.
Using javascipt allows many different actions easily.


"<"input name='action' type='hidden' value='action1'">"
or:
"<"input name='action' type='hidden' value=''">"

"<"input type="button" name="myButton" value="Button 1" on Click="javascript:submitForm( 'action1' );"">"
"<"input type="button" name="myButton2" value="Button 2" on Click="javascript:submitForm( 'action2' );"">"
"<"input type="button" name="myButton3" value="Button 3" on Click="javascript:submitForm( 'action3' );"">"
"<"input type="button" name="myButton4" value="Button 4" on Click="javascript:submitForm( 'action4' );"">"

function submitForm( action )
{
document.forms[0].action.value = action;
document.forms[0].submit();
}


on the form, you simply do a post:
"<"form name='myForm' method='POST' action='[SERVLET_URL]'">"


Your servlet should act as a traffic cop and pass on the request. You can find the action easily in your java code:

String action = (String) request.getParameter( "action" );

In the above examples, the value of the String 'action' will either be "action1", "action2", "action3", or "action4".

There are many other variations, but hopefully this is a simple and straight-forward option.

- James
18 years ago