Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Context Path in Struts2 JSP?

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

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic