• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Javascript and JSTL

 
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="<c:out value='${FromUrl}' />" />
<c:if test="${fromurlattribute eq null}" >
<c:set var="fromurlattribute" value="/journey/gd/home.do" />
</c:if>
document.GDHomePageForm.action ="<c:out value='${fromurlattribute}' />";
document.GDHomePageForm.submit();
}

Please help to identify the problem.

Thanks,
Neeraj.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<c:set var="fromurlattribute" value="<c:out 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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You don't need the <c:out> 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic