aspose file tools*
The moose likes Servlets and the fly likes jsp tag... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp tag..." Watch "jsp tag..." New topic
Author

jsp tag...

mendy smith
Greenhorn

Joined: Jan 30, 2001
Posts: 19
Is there a way to pass an attribute without passing a value actually to it in the jsp file to the jsp tag. I just want to check whether it is null or not, basically make this optional.
Thanks,
Apreciate your help!
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Mendy,
I came across this example in Marty Hall's book where the 'repts' atribute could be null if the user doesn't send from browser. Please take a look at. The 'RepeatTag.java' file's setReps method works intelligently when the incoming arg is null.
He just uses this HttpRequest object inside tag.

<csajsp:repeat reps='<%= request.getParameter("repeats") %>'>

To simulate null value to this attribute , don't pass any 'reps' parameter from the browser url.

Just http://localhost/yourappln/RepeatTag.jsp will do!
To pass some val http://localhost/yourappln/RepeatTag.jsp?reps=10



regds
maha anna

[This message has been edited by maha anna (edited March 30, 2001).]
mendy smith
Greenhorn

Joined: Jan 30, 2001
Posts: 19
Thanks maha anna for the suggestions!
My point is i don't want to pass a value to this reps attribute in my .jsp file. I want to check whether this attribute is present(null) or not. Can we do the following?
From your example:
------------------
//this is part of my .jsp file
<csajsp:repeat reps>
//set method in tag class
public void setReps(String reps)
{
}
Thanks,
Appreciate any further suggestions!

maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Mendy,
I checked your point. We can't just use the attribute name alone without any value!. We have to atleast specify '' OR "". IN other words, the following code is not allowed. When I tried with this code and called the jsp file from browser, got the famous 500 error saying "attribute reps must hava a value"
regds
maha anna
// This code is illegal
<csajsp:repeat reps>
<LI><csajsp rime length="40" />
</csajsp:repeat>
// This code is OK!
<csajsp:repeat reps=''>
<LI><csajsp rime length="40" />
</csajsp:repeat>

[This message has been edited by maha anna (edited March 30, 2001).]
 
Consider Paul's rocket mass heater.
 
subject: jsp tag...