wood burning stoves 2.0*
The moose likes JSP and the fly likes c url doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "c url doubt" Watch "c url doubt" New topic
Author

c url doubt

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Hi Guys,

Can anyone explain me with a simple example about the use of <c:url> tag?? I appreciate your help.


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Do you have a copy of the JSTL Specification? If not, you should. Link can be found in the JSP FAQ.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
Hi fella,

It is simple and straight forward
Say, you wanna put a link that is dependent on session ...

<a href="<c:url value='/myapp/mysesPage.jsp' />">CLICK HERE </a>

This is same as cumbersome response.encodeURL("/myapp/mysesPage.jsp"); in servlets

What this really does is..if the client is cookie disabled, the ;jsessionid=sdlkfsd32423rewfhcjd will be appended to the actual URL...

this ID will be identified by the container in a vendor specific manner to track the session ID..

hope this helps


Theepan Thevathasan
SCJP 1.4, SCWCD 1.4, SCMAD 1.0 SCBCD 1.3, MCP(.Net Frm 2.0 App Dev Fdn)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

To help keep the markup cleaner, I will frequently not embed <c:url> in an anchor tag. Rather, I'll do something along the lines of the following:



Which makes the HTML <a> tag easier to read. (Tags within tags just look so funky).
[ February 03, 2007: Message edited by: Bear Bibeault ]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Theepan and Bear,

Thanks for your explanations!
Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
You are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c url doubt