File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 56163
    
  13

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

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



[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to get Context Path in Struts2 JSP?
 
Similar Threads
request.getParameter in struts2
struts2 CreateQurey
json in struts2
Struts2 Iterator
Struts2 variable inside javascript