• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to keep the selected value ?

 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii

I am trying to display the selected value after submitting my page.
Here I am using the below code:


But, in the above written code, "thisdate" inside the option tag is giving me error. "thisdate cannot be resolved"

I couldn't see any mistakes in my code.

Am I missing something?? Please help me out..

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is more about JSP than HTML, so it has been moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the expression

<%= thisdate.equals(myDate)? "selected" :"" %>

what is thisdate?

You did not show us where and how the thisdate scripting variable was defined.
[ October 02, 2006: Message edited by: Bear Bibeault ]
 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my code, the very first line says it as :

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you post the code to the entire select list?
This will give us a better idea of what's going on in your JSP.
 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

This is the code I am using in my JSP SELECT OPTION.


Here, "thisdate" is the name of the SELECT element on the form. I am not using it anywhere else on my JSP page.
And while I 'll access my page, it gives me this error "thisdate cannot be resolved"
I don't have the access right now, I 'll drop the code again as soon as I 'll reach to office.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manu Dhanda:
In my code, the very first line says it as :



That is just client-side HTML template text and has nothing at all to do with your JSP code.

If you want to compare the submitted value you'll need to get it to the JSP page using a server-side mechanism.
[ October 02, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could benefit from reading this article which outlines how JSPs operate.
[ October 02, 2006: Message edited by: Bear Bibeault ]
 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, Now this is my entire JSP file.


Everything is working fine in this JSP file.
It started me giving problem when I inserted the following in my <OPTION> tag.



Earlier. I mean to say "The very first line of my code".. It was respective term to this post only, not to my entire JSP file.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manu Dhanda:

Earlier. I mean to say "The very first line of my code".. It was respective term to this post only, not to my entire JSP file.


Yes, I understood that.



It started me giving problem when I inserted the following in my <OPTION> tag.



That's because, as I already explained, the line containing the select element declaration is meaningless to your JSP code. It might just as well have been "asjdhsdajhgdjagfjsgdafjdhgfjdshgfjdsfaj" as far as your JSP code is concered. It's just template text.

Did you read the article I linked to? You apparantly have a fundamental (and common) misunderstanding regarding how JSPs operate and what is meaningful on the server side versus the client side.
[ October 02, 2006: Message edited by: Bear Bibeault ]
 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault..

I got it where I was making the mistake.

Changing "thisdate" to "request.getParameter("thisdate")" resolved my problem.

The document 'n then your following words helped me to find out like where I was making the mistake.

That's because, as I already explained, the line containing the select element declaration is meaningless to your JSP code. It might just as well have been "asjdhsdajhgdjagfjsgdafjdhgfjdshgfjdsfaj" as far as your JSP code is concered. It's just template text.


Thanks.
Manu
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent. Understanding the fundamental workings of JSP will make them so much easier to work with.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic