• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

a doubt in servlet invocation..  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator

Thanks a lot Manohar..
good idea..
regards,
vidya.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!