Solved

Unable to retrieve parametername of the selection box through a servlet

Posted on 2003-10-23
5
166 Views
Last Modified: 2010-04-01
Hi All,
 I have a JSP which when executed calls a servlet.
Tis Jsp has couple of text fields and checkboxes and two selection boxes.
WHen I make a call to get parameternames for all the components in the JSP. I aget everything except the names of the selection boxes.
Anyhelp soon will be appreciated.
Thanks
Azhar
0
Comment
Question by:aarschie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9610825
that's b/c you have to select an item in the selection box... otherwise no value from it will be passed (hence no parameter).
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 500 total points
ID: 9610835
just make a default option like:

<option value=-1 selected>Choose whatever</option>

then just make sure the user selects an option
0
 
LVL 4

Expert Comment

by:vk33
ID: 9612180
Make sure you've defined the names of selection boxes in the form. And check out the spelling in both the form and the servlet.

Regards!
0
 
LVL 4

Expert Comment

by:vk33
ID: 9612209
JSP code:

<form action="Demo" method="POST">
<select name="sel">
      <option value="123">bla-bla-bla</option>
</select>
<input type="submit">
</form>

Servlet code:
PrintWriter out = null;
try {
      out = response.getWriter();
      String param = request.getParameter("sel");
      out.println (param);
} catch (Exception e) {
      if (out != null)
            out.println (e.toString());
}

It works fine, I've checked...

Good luck!
0
 
LVL 4

Expert Comment

by:vk33
ID: 9612231
Khm, sorry, I misunderstood the question... Include the following to the servlet code above:

Enumeration enumParams = request.getParameterNames();
while (enumParams.hasMoreElements())
   out.println((String)enumParams.nextElement());

But still it works fine, you'll get "sel" param name printed out.
Tested on Tomcat-4.1.18

Regards!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
String format issue 13 93
Is possible to make a jsp script work with oracle wallet? 7 106
own marker interface 1 61
jsp login check 12 67
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question