• Post Reply Bookmark Topic Watch Topic
  • New Topic

ways of getting context name in javascript  RSS feed

 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to load page as follows

var frame = document.createElement('iframe');
frame.src = "/birthDayReminder/search.htm";

here i am giving context name as hard coded value

is there any way to get this context name dynamically

some work around in java is
1] define hidden variable like
<input type="hidden" id="contextName" value="<%=request.getContextPath()%>">

2] access this variable in java script as follows
var contextName=document.getElementById("contextName");frame.src = contextName.value+"/search.htm";
[ October 29, 2007: Message edited by: ganesh pol ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see this JSP FAQ entry.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very helpful answer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!