aspose file tools*
The moose likes JSP and the fly likes Javascript and JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Javascript and JSTL" Watch "Javascript and JSTL" New topic
Author

Javascript and JSTL

Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
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

Joined: Jan 10, 2002
Posts: 61010
    
  65

<c:set var="fromurlattribute" value="<cut value='${FromUrl}' />" />


You cannot use a custom actioin as the attribute value of a custom action.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
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

Joined: Nov 25, 2003
Posts: 315
<%
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

Joined: Nov 25, 2003
Posts: 315
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

Joined: Jan 10, 2002
Posts: 61010
    
  65



You don't need the <cut> at all in that context.
[ June 12, 2006: Message edited by: Bear Bibeault ]
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
hi,

I got it, what you meant to say.

Thanks,
Neeraj.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Javascript and JSTL