simple jsp issue

I have a menu link M1  ( action url) .
 when user clicks on this link , it shows a  JSP page ....say A.jsp

However , user can come to this same A.jsp page from other link (action url) as well.

Now my problem is , I want to hide a div element in A.jsp whenever user comes to this A.jsp page by clicking M1 link.

I am stuck right here.....because  I am unable to detect whether user is coming to this A.jsp page via clicking M1 link or through clicking other link.

Please guide.
cofactorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rrzCommented:
If the links are on different pages, then you could try using
String referrer = request.getHeader("referer"); 

Open in new window

in A.jsp . If you are using JSTL then use
${header.referer}

Open in new window

in your test attribute.   Alternatively you could add a parameter to each link and then get the parameter in  A.jsp
0
cofactorAuthor Commented:
>>>Alternatively you could add a parameter to each link and then get the parameter in  A.jsp

Ok. I liked this idea....You know  when clicked it goes to action class ....and  then it goes to A.jsp

Do you want me to set the parameter in request attribute  again  in Action class ?  ( so that it is available in A.jsp )

Please clarify bit more at this step .
0
rrzCommented:
I don't use a framework.   Which one are you using?  Maybe an expert will help you. Please tell us which one.  
Do you want me to set the parameter in request attribute
No, that won't work.  If you are clicking a link, then you sending another request. You could set a session-scoped variable.  Something like
session.setAttribute("cameFrom", "M1")

Open in new window

In A.jsp use ${cameFrom} or session.getAttribute("cameFrom")
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

cofactorAuthor Commented:
>>>Please tell us which one.  
Struts 2

>>>>No, that won't work.

session is not a good idea here ...because who will clear this session variable .  I think request will suit here.

You know my other link is basically resides in the A.jsp itself.  Its a search submit button which has the same action url as M1 link.

so ..the story  is ....  user can come to this A.jsp page by clicking M1 link  ...and then user can click on Search button in A.jsp which basically returns the same A.jsp

Problem is ...I am unable to capture whether user is clicking M1 link or clicking Search button to submit form.....both of them calling the same action url.

any thoughts here ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
I don't do Struts. So I can't give you expert advice.  
Problem is ...I am unable to capture whether user is clicking M1 link or clicking Search button to submit form.....both of them calling the same action url.
Seems to me, my second idea might be the way to go. Why can't you add a parameter to the links?   You should post your code that has the links in it.

 You need a Struts expert here. Maybe you should delete this question and open another question with Struts2 in the title.
0
cofactorAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.