Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

manipulating string param EL

 
Peter Maxwell
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy fellas,

I have a combo box which might take values like
1.Orange
2.Apple
in my "index.html" file which I submit to "GetList.jsp" file.

Here at "GetList.jsp", i would like to have only the part of the "fruit" param (viz., the number 1,2,etc.,) and not the whole thing ("1.Orange","2.Apple",etc.,)
which i submit to another jsp as a hidden param like the code below:


But the code above makes use of expressions which i learnt is bad as scripting should be avoided in jsp.
So is there a way, i can do the same thing using a EL.
${param.fruit} gets me the whole value. How can i get part of it?

Any help would be appreciated.
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

A couple of things:

It's not a "combo box", no such control exists on the web. Please read this for more information.

Secondly, rather than trying to parse out part of the display value, use the value attribute on the option elements to submit extactly what you need and nothing else.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also want to read through this article to find out why submitting directly to a JSP is not considered a best practice.
 
Peter Maxwell
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault for the quick reply.

Bear Bibeault wrote:Welcome to the Ranch.

A couple of things:

It's not a "combo box", no such control exists on the web. Please read this for more information.


Well that's so embarassing , as i've always called it that way.


Bear Bibeault wrote:
Secondly, rather than trying to parse out part of the display value, use the value attribute on the option elements to submit extactly what you need and nothing else.

Thanks, that looks like a simple and elegant solution for this and that solves my problem. But just out of curiosity is there anyway that EL can do this?

Bear Bibeault wrote:
You might also want to read through this article to find out why submitting directly to a JSP is not considered a best practice.

Thanks for the link. I'll go through that.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Maxwell wrote:
Well that's so embarrassing , as i've always called it that way.
It's a common nomenclature usage that somehow got started. No need for the red face.

Thanks, that looks like a simple and elegant solution for this and that solves my problem.

Just basic HTML.

But just out of curiosity is there anyway that EL can do this?

Not on its own. Remember, the EL is purposefully hobbled to only allow display type interaction as a way to dissuade people from doing non-view calculations in JSPs. However, the fn class of EL functions in the JSTL allow a certain amount of string manipulation. But again, it should not be misused for data processing.
 
Peter Maxwell
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Peter Maxwell wrote:
Well that's so embarrassing , as i've always called it that way.
It's a common nomenclature usage that somehow got started. No need for the red face.

Thanks, that looks like a simple and elegant solution for this and that solves my problem.

Just basic HTML.

But just out of curiosity is there anyway that EL can do this?

Not on its own. Remember, the EL is purposefully hobbled to only allow display type interaction as a way to dissuade people from doing non-view calculations in JSPs. However, the fn class of EL functions in the JSTL allow a certain amount of string manipulation. But again, it should not be misused for data processing.


Thanks a lot for your time and help, Bear.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. That's why the Ranch is here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!