aspose file tools*
The moose likes Servlets and the fly likes drop down list for servlet  form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "drop down list for servlet  form" Watch "drop down list for servlet  form" New topic
Author

drop down list for servlet form

Harrison Id
Greenhorn

Joined: Sep 23, 2008
Posts: 1
Can someone help me with this code.
I want to put a dropdown list in this servlet form, please I need help in rewriting this code. (On the MDA Name i need a dropdown list)

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InboundCaseLog extends HttpServlet
{protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String mess1 = req.getParameter("message");
out.println("<HTML><HEAD><TITLE>Inbound Case Log</TITLE></HEAD>"+'\n'+
"<BODY BGCOLOR='lightgreen'>"+'\n'+
"<P><H2 ALIGN=CENTER>NEW INBOUND CASE LOG ENTERING </H2");
out.println("<html><head><title>Inbound Case Log</title></head>");
out.println("<body bgcolor = 'lightblue'>");
out.println("<form method = \"post\" action = \"http://localhost:8080/servlet/Relay\">");
out.println("ReferralID: <INPUT type = \"TEXT\" size = 20 name = \"RefID\"><P>");
out.println("MDA Name: <INPUT type = \"TEXT\" size = 20 name = \"MdaName\"><P>");
out.println("MDA Contact Name: <INPUT type = \"TEXT\" size = 20 name = \"MdaC\"><P>");
out.println("Contact TelNo: <INPUT type = \"TEXT\" size = 20 name = \"Tel\"><P>");
out.println("Contact Position: <INPUT type = \"TEXT\" size = 20 name = \"Position\"><P>");
out.println("Date Recieved: <INPUT type = \"TEXT\" size = 20 name = \"DateRec\"><P>");
out.println("Project Name: <INPUT type = \"TEXT\" size = 20 name = \"PName\"><P>");
out.println("<INPUT type = \"submit\" value = \" Send Details\"<P>");
out.println("<INPUT type = \"hidden\" name = \"choice\" value = \"CaseLogEntry\"><P>");
out.println("</form></body></html>");
}
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
I suggest the following steps:
1. Create a static HTML page that corretly displays the list.
2. Use that as a guide to creating the page with servlet output statements
3. If it doesnt work, use the browser view-source and compare what your servlet is writing with the static page.

Bill
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Harrison I, please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Is there any reason that you must do this in a servlet? Generating HTML markup in Java strings is a pain as you have discovered. This is a much better task for a JSP.
Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
out.println("MDA Contact Name: <select name = \"MDA\">");
out.println("<option value ='value1'>Value 1 </option>");
out.println("<option value ='value2'>Value 2</option>");
out.println("<option value ='value3'>Value 3</option>");
out.println("</select> <P>" );
 
Don't get me started about those stupid light bulbs.
 
subject: drop down list for servlet form