aspose file tools*
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
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: 61766
    
  67

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?