Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Jsp equivalent to Php code

 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am trying to make a navigation bar for my jsp page following a Php tutorial
http://www.alistapart.com/articles/keepingcurrent/ .
The Php tutorial gives a name to each page like

Can you please tell me how can I equivlently give a name to my jsp pages?

secondly,it checks to see which page the user is currently on,like this:


Can someone please tell me the equivalent to this in Jsp??I am sorry for the incovenience because the forum was not allowing me to post < and > signs.

your help would be greatly appreciated.Thanks
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that there's an exact equivalent. JSPs are really servlets, so the concept of a "page" is a bit different from PHP. Since you can have JSPs inside of JSPs, it might be hard for some fragment to figure out which page it's really inside of.

Typically, you want to use a JSP just for the view/presentation, and any navigation should be handled by pure servlets. In other words, when the user performs an action on your JSP, that request should go up to a servlet who then decides what JSP to send the user to. The servlet could set an attribute (variable) in the response, and then a script in your menu fragment could access that attribute to figure out which one is the current page.

You might want to read up on taglibs and the Java Expression Language.

Here's a PDF on integrating servlets and JSPs, linked off of the coreservlets.com website:
http://csajsp-chapters.corewebprogramming.com/CSAJSP-Chapter15.pdf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic