File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Frameworks
»
Struts
Author
How to get Context Path in Struts2 JSP?
Konstantin Netkachev
Greenhorn
Joined: Jul 24, 2009
Posts: 15
posted
Jan 20, 2011 06:19:21
0
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
I like...
posted
Jan 22, 2011 11:29:12
0
You can simply use:
<s:url id="contextUrl" action="" namespace="" /> var contextPath = "<s:property value="#contextUrl"/>"
SCJP 91%, SCWCD 97%
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56163
13
I like...
posted
Jan 22, 2011 11:58:19
0
var contextPath = "${request.contextPath}" also not working
request
is not an EL builtin variable. Rather, to do this easily without all the Struts baggage:
var contextPath = "${pageContext.request.contextPath}"
[
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
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter