Solved

JSP - How to identify the link I clicked?

Posted on 2004-03-30
3
381 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:mayankeagle
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

757 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

21 Experts available now in Live!

Get 1:1 Help Now