• 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

how can I determine which link was clicked?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,

in my servlet, I am outputting onto the browser three lines:

A
B
C

When A, B or C are clicked, they will all redirect to another servlet. Now in this new servlet, I want to perform an action depending on which of A, B or C was clicked. How can I determine this? If I was using Java Swing I would use the event source, but how can I do something similar in my servlet?

thanks
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can pass parameter to new servlet, javax.servlet.http.HttpServlet. based on the parameter value decide what you want to do. Use following API to get the value of parameter.

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Hi-jack removed]
 
Jitendra Takalkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If A, B and C lines are anchor links then you can pass parameter using query string.

For example:
Assume servleturi map to your new servlet.

http://host:port/webapp/servleturi?type=A for line A
http://host:port/webapp/servleturi?type=B for line B etc

Use getParameter() method to get the value of parameter - type, as follows

String parameterType=HttpServletRequest.getParameter("type");


 
James Byars
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jitendra Takalkar wrote:If A, B and C lines are anchor links then you can pass parameter using query string.

For example:
Assume servleturi map to your new servlet.

http://host:port/webapp/servleturi?type=A for line A
http://host:port/webapp/servleturi?type=B for line B etc

Use getParameter() method to get the value of parameter - type, as follows

String parameterType=HttpServletRequest.getParameter("type");





Great answer, that helps a lot

thanks
 
Eduardo Bueno
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[hijack removed]
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Removed answer for hijacked thread]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thread hi-jack removed.
 
reply
    Bookmark Topic Watch Topic
  • New Topic