Solved

JSP - How to identify the link I clicked?

Posted on 2004-03-30
3
393 Views
Last Modified: 2012-05-04
I've been doin programming using WebSphere (Struts, Bean). In the menu bar I've two links called A&B. My page mock-up is common for both A&B pages except in B I'm having two more buttons. So, I've want to have only one JSP page, but based on the link(A or B) clicked, I want to show show different thing. My question is how do I identify which link I clicked? Please advise. Thanks a lot.
0
Comment
Question by:Sekar1971
3 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 10723210
On click of each link, you can call a specific Java script function which will do your stuff. Something like:

onClick="javascript:clickA();" // -> for A

onClick="javascript:clickB();" // -> for B

You can do specific stuff in clickA () and clickB () functions.
0
 
LVL 2

Accepted Solution

by:
rqs earned 125 total points
ID: 10739334
I'm not sure if I understand the problem correctly but if,
what you want is a single JSP program that would behave
differently depending on the link clicked to get to that JSP page

here's what I suggest:

on the HTML menu bar you were referring,
<a href="nameofjsppage.jsp?Menu=A">Menu A</a>
<a href="nameofjsppage.jsp?Menu=B">Menu B</a>

and then on the JSP code, something like this

//request is HttpServletRequest variable

String menu = request.getParameter("param1");
String valueA = "A";
String valueB = "B";

if (menu.equals(valueA))
{
//do stuff that ought to be done when menu A is selected

}
else if (menu.equals(valueB))
{
//do stuff that ought to be done when menu B is selected
}

tell me if this helped
0
 

Author Comment

by:Sekar1971
ID: 10750609
Hi rqs, Thanks for the response. I did it in a different way. Decalred a hidden variable called linkType and passed linkType="A" and linkType="B" in the links. Using struts logic.equal syntax, based on the linkType I got my pages. Thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now