• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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.
 
I am going to test your electrical conductivity with this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!