• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a doubt in servlet invocation..

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..
I am relatively new to servlets, and this is my first post here.
Is there any way i could know which form triggered the servlet, like if I submitted one form, i need the servlet to do one task, and if I submitted another form, i need the same servlet to do another task.
I am thinking of checking for a condition in the servlet's doGet() method, and accordingly , call approppriate methods.
Is it possible i could check which form triggered it, inside its doGet() method ? like, if the request is from form1, do this, and if the reguest is from form2, do something else ..
any help would be appreciated.
thanks..
Vidya.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Vidya!
In form maintain one hidden field and give some name say "form1". After submit in servlet get that parameter then do what ever u want to do for form1
Like this.....
In form
<HTML>
<BODY>
<FORM>
.......
.......
<Input type="hidden" name="FormName" value="Form1">
.......
.....
</FORM>
</body>
</HTML>
In servelt
public void doGet(request,response)
{
///////////
String strFormName=(String)request.getParameter("FormName");
....
.......
if(strFormName.equals("Form1"))
{
////Action for Form1 goes here..........
}
else if(strFormName.equals("Form2"))
{
////Action for Form1 goes here..........
}
///And so on......
..........
}
Hope this might help u..
Rgds
Manohar
 
Vidya Sreenivasan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks a lot Manohar..
good idea..
regards,
vidya.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic