File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Context Path in Struts2 JSP?

 
Konstantin Netkachev
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 88
Java Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can simply use:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
var contextPath = "${request.contextPath}" also not working

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


 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic