This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to get values from combo box in servlet  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new here. I get a problem in servlet.
Ok... I have a list of data (which from db) in combo box in jsp. So I need to pass the value to servlet.

JSP:
<SELECT name="prefix" size="0" onchange="setValueComboBox()">
<%=displayMember.displayUsertitleList(Member.getPrefix())%>
//displayUsertitleList will call a function
</SELECT>

<SERVLET>
String sTitlename = (req.getParameter("prefix"));

**********
The problem is if the data "Profesor" I will get the sTitlename = Profesor
BUT if the data is "Associate Profesor" I will get "Associate" only. The Profesor is lost.

So...could anybody help me.
TQ
 
Author and ninkuma
Marshal
Posts: 66799
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Firstly, calling an select element a Combo Box is incorrect. There is no native equivalent to the desktop control known as a Combo Box in HTML.

Secondly, do a View Source on the rendered HTML that is sent to the browser for the JSP page. I am almost certain that you will find that you forget to put quotes aorund your attribute values. Hence, the break on a whitespace character.
 
Nur Cahaya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I'm beginner in this are, I don't get your point. Sorry.
So, could you correct me.

Help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66799
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes in your HTML should be quoted. In other words:

<option value=something or other>

is wrong. It should be:

<option value="something or other">

Technically, HTML let's you get away with leaving off the quotes if the value is a single word, but that's sloppy and it is encouraged to always quote the attribute values. in XHTML, the quotes are mandatory.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!