• 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

Need help on chaining servlets

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building an application where I need to delete some users. I am getting the username from a form and then checking if it exists in the userlist. If yes, then I need a confirmation from the user to delete that user. Once confirmed, the user will be deleted.
So, I propose to use two servlets. One that will get the parameters from the form and then display the dynamic confirmation page having a submit button as a confirmation. This button would then fire a next servlet which would delete the user and then display that user has been deleted.
Kindly suggest how can I pass the values from one servlet to another. Some tutorial and sample code would be of great help.
And ofcourse, thanks in advance.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can forward from one servlet to another. And if you put the form values in a variables use the setArribute and getAttribute methods to transfer the variables from one servlet to another. So in the first servlet, you might have something like this:
request.setAttribute("nameYourParameter", "ValueYouWantPassed");
RequestDispatcher d = request.getRequestDispatcher("servlet2");
d.forward(request, response);
In servlet 2, you get the parameters this way:
String var1 = (String)request.getAttribute("nameYourParameter");
[This message has been edited by Jeff Sunder (edited July 23, 2001).]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Mike D",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic