This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to get Context Path in Struts2 JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get Context Path in Struts2 JSP?" Watch "How to get Context Path in Struts2 JSP?" New topic
Author

How to get Context Path in Struts2 JSP?

Konstantin Netkachev
Greenhorn

Joined: Jul 24, 2009
Posts: 15
I want to initialize Context Path global javascript variable in JSP.

var contextPath = "<s:property value="#request.contextPath"/>" doesn't work.
var contextPath = "${request.contextPath}" also not working

var contextPath = "<%=request.getContextPath()%>" is working. But I don't want to use java code in JSP.

So is there possibility to get Context Path in Struts2 JSP without java code?
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

You can simply use:



SCJP 91%, SCWCD 97%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

var contextPath = "${request.contextPath}" also not working

request is not an EL builtin variable. Rather, to do this easily without all the Struts baggage:



[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get Context Path in Struts2 JSP?
 
Similar Threads
request.getParameter in struts2
Struts2 variable inside javascript
Struts2 Iterator
struts2 CreateQurey
json in struts2