Fabio Entertainment
This is my personal blog, any comment are welcome.


Struts Request URI

Normally when I want to get the current page URI in JSP, I can code like this:

String currentUri = request.getRequestURI();

But unfortunately in Struts, I cannot get the current page URI with the above same code. By doing so, I will get the template file URI but not the current page URI.

For Struts, I will need to code like this:

String currentUri = (String)request.getAttribute("javax.servlet.forward.request_uri");

But how if all of my pages are in Struts or JSP? In this case, I will need to get it from Struts URI by default, else wise get from JSP URI.

String currentUri = (String)request.getAttribute("javax.servlet.forward.request_uri");
if (currentUri == null) {
currentUri = request.getRequestURI();
}

Like this, I can handle both case.

Tweet This!Share on FriendFeedTechnorati LinksSave to del.icio.usDigg This!Share on Facebook

posted by Fabio | 04/06/2008 12:03:51


Post a Comment
* You need to have JavaScript enabled in order to continue.
* Please enter your name, spammer's post will be filter out.
Author:
E-mail:
Website:
Text:
* Adds [url] and [/url] around Internet Addresses.
* [url]http://url[/url] or [url=http://url]URL text[/url].
* Adds [img] and [/img] around Internet Images.
* Images width should less than 500 pixels.
* Adds [code] and [/code] around Programming Code.
* Emoticons
:):(
:)):((
:P:D
;)X(

Contact Me

Last Update : 03/10/2009 03:55:33

LOG IN/OUT

THEME





  • Putrajaya Night Marathon 42km #64
    06/02/2010 (04:19:40)
  • New Balance Pacesetters 30km
    17/01/2010 (02:45:36)
  • Penang Bridge International Marathon 21.0975km #119
    22/11/2009 (01:55:08)
  • New Balance Pacesetters 15km #256
    17/05/2009 (01:31:22)
  • Malakoff, KL 12km #50
    20/12/2009 (00:59:56)
  • Shape & Men's Health Night Run 11.5km
    25/07/2009 (01:03:00)
  • Mizuno Wave Run 11km
    25/10/2009 (01:03:00)
  • Siemens Run 10km
    19/07/2009 (00:50:00)

    Loading...






© Copyright 2004-2010 Fabio Entertainment. All Rights Reserved.
This site is optimised for Internet Explorer 6, Firefox 2 and above.