Solved

JSP - How to identify the link I clicked?

Posted on 2004-03-30
3
411 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 123
add projects t working set in maven 2 37
Output in PHP throwing alignment of data off issue 12 53
DTD and JAVA versions 1 27
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.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

685 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