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

jstl variable handling

Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi All
I want to compare a jstl variable like ${StoneAKAForm.code}
with a jsp integer variable..
Anybody have any idea .
Thanks in advance.

Khushwinder


Khushwinder
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The need to do this is usually an indicator that JSTL isn't being used properly. JSTL is meant for scriptless JSPs where all of the heavy lifting is done with Java objects before context is ever forwarded to the JSP for markup.

If you were comparing objects, you could simply bind your scriptlet variable to request scope with request.setAttribute("name", value) and then compare the two using EL. However, in this case, you're scriptlet variable is an int which is a native type and can't be bound directly to scope without being wrapped in the Integer type.

If you really have to do this, you might be better off dereferencing ${StoneAKAForm.code} from within your scriptlet and doing the comparison there.

Maybe if you tell us why you need to compare these, someone can suggest a better strategy.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Thanks a lot for your reply.
But my problem is that i have to do this because of some constraints.
There is no other option.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

From within your scriptlet, you could use PageContext.findAttribute to locate
the StoneAKAForm object, then call its getCode method and do the comparison there.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

"khushwinder khushwinder", please check your private messages immediately.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jstl variable handling