• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get values from combo box in servlet

 
Nur Cahaya
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
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: 65530
108
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!