Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drop down list for servlet form

 
Harrison Id
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harrison I, please check your private messages.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>" );
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic