Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript and JSTL

 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to dynamically set the action of form inside a javascript function. I am not getting the correct values. It add some extra charecters with it like < etc..



function setSubmit() {
<c:set var="fromurlattribute" value="<cut value='${FromUrl}' />" />
<c:if test="${fromurlattribute eq null}" >
<c:set var="fromurlattribute" value="/journey/gd/home.do" />
</c:if>
document.GDHomePageForm.action ="<cut value='${fromurlattribute}' />";
document.GDHomePageForm.submit();
}

Please help to identify the problem.

Thanks,
Neeraj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:set var="fromurlattribute" value="<cut value='${FromUrl}' />" />


You cannot use a custom actioin as the attribute value of a custom action.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just started to use jstl. Please inform, if this is a practice one should follow or we cannot do it this way. since I am able to set the values for the var "fromurlattribute"

Thanks,
Neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
String fromUrl= (String)request.getAttribute("FromUrl");
if(fromUrl == null || fromUrl.equals(""){
fromUrl="/journey/gd/home.do"
}
%>
function setSubmit() {
document.GDHomePageForm.action ='<%= fromUrl %>';
document.GDHomePageForm.submit();
}

This is working fine.. I need to convert this to jstl. It will be great if somebody can help.

Thanks,
Neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry few typing mistakes were there..


<%
String fromUrl= (String)request.getAttribute("FromUrl");
if(fromUrl == null || fromUrl.equals("")){
fromUrl="/journey/gd/home.do";
}
%>

function setSubmit() {
document.GDHomePageForm.action ='<%= fromUrl %>';
document.GDHomePageForm.submit();
}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You don't need the <cut> at all in that context.
[ June 12, 2006: Message edited by: Bear Bibeault ]
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I got it, what you meant to say.

Thanks,
Neeraj.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic