This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make a decision on a jsp form ?

 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have the following HTML code in my jsp

I retrieve a value from session using my JSP

<%=session.getAttribute("status")%>

in response i get a P,F,A for (Pass,fail, and absent)

Now There are 3 radio buttons on my jsp page:
but i only want one of the options marked on the basis of the above result how can i do that ??



I guess i can do something like:



but thats not working.. I would like to know what you guys suggest..thanks...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote:but thats not working..

That's not very helpful. Read: ItDoesntWorkIsUseless.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest ditching the scriptlets and switching to JSTL and EL. Here's how you would do that in EL:
 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Adam Zedan wrote:but thats not working..

That's not very helpful. Read: ItDoesntWorkIsUseless.


sorry i was unclear before... my bad.
anyways i tried to use the following code in my jsp but the option did not get marked porbably cause checked did not get written
<input name="status" type="radio" <% if(session.getAttribute("status")=="P"){checked} %> /> Pass
 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote:
Bear Bibeault wrote:
Adam Zedan wrote:but thats not working..

That's not very helpful. Read: ItDoesntWorkIsUseless.


sorry i was unclear before... my bad.
anyways i tried to use the following code in my jsp but the option did not get marked porbably cause checked did not get written
<input name="status" type="radio" <% if(session.getAttribute("status")=="P"){checked} %> /> Pass


thanks that did the trick but could you also tell me how to accomplish the same task using scriptlet?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote:thanks that did the trick but could you also tell me how to accomplish the same task using scriptlet?


Was that referring to my post? If so, no, I couldn't. I don't use them any more.
 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing... initially when an attribute doesnot exist and on my jsp page i use

<td><input type="text" name="textname" value=<%=session.getAttribute("name")%> /></td>

I get NULL value. Is there any way by which i can just have an empty value ?? or will i have to check for NULL and replace it with empty ??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote:but could you also tell me how to accomplish the same task using scriptlet?

If it's working, why would you want to resort to discredited scriptlets?
 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Adam Zedan wrote:but could you also tell me how to accomplish the same task using scriptlet?

If it's working, why would you want to resort to discredited scriptlets?


I guess i should stick to JSTL and EL.. The best way is to not use them.. Thanks for the encouragement...
though i figured it out lol.. just had to use out.println(" checked") in the condition.. But ill stick to Extended language Version... thanks guys..
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote:One more thing... initially when an attribute doesnot exist and on my jsp page i use

<td><input type="text" name="textname" value=<%=session.getAttribute("name")%> /></td>

I get NULL value. Is there any way by which i can just have an empty value ?? or will i have to check for NULL and replace it with empty ??


Well, yes. The EL automatically does that for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic