?
Solved

JSP - How to identify the link I clicked?

Posted on 2004-03-30
3
Medium Priority
?
452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
Simple Linear Regression

764 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