• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp tag...

 
mendy smith
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic