Help: No Parameters, HTML Output from Java Servlet

I have a Java Servlet that reads parameters passed from an HTML form and displays them to another HTML page. I know the servlet is being invoked; however, I am not seeing any HTML output. Sending the output to a file reveals the parameters are coming in as NULL as well.

I attempted a simple sample app with the same results. Here is what I am running:

The HTML Form:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE>Collecting Three Parameters</TITLE>

</HEAD>

<BODY BGCOLOR="#FDF5E6">

<H1 ALIGN="CENTER">Collecting Three Parameters</H1>

<FORM ACTION="ThreeParams">

First Parameter: <INPUT TYPE="TEXT" NAME="param1">

Second Parameter: <INPUT TYPE="TEXT" NAME="param2">

Third Parameter: <INPUT TYPE="TEXT" NAME="param3">

<CENTER><INPUT TYPE="SUBMIT"></CENTER>

</FORM>

</BODY>

</HTML>

The Java Code:

public class ThreeParams extends HttpServlet {

public void doGet(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html");

PrintWriter out = response.getWriter();

String title = "Reading Three Request Parameters";

out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +

"Transitional//EN\">\n" +

"<BODY BGCOLOR=\"#FDF5E6\">\n" +

"<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +

"<UL>\n" +

" <LI><B>param1</B>: "

+ request.getParameter("param1") + "\n" +

" <LI><B>param2</B>: "

+ request.getParameter("param2") + "\n" +

" <LI><B>param3</B>: "

+ request.getParameter("param3") + "\n" +

"</UL>\n" +

"</BODY></HTML>");

}

}

What happens when I "submit" from the form is the same form reloads with the query string in the URL: "http://localhost:8080/ThreeParams/?param1=1&param2=2&param3=3"

Any assistance with either (or both) would be thoroughly appreciated:

a) why the parameters are not being passed correctly to the servlet

b) why the HTML output page is not displayed

Thanks in advance!

- Steve

[2435 byte] By [swestenzweiga] at [2007-10-2 23:56:37]
# 1
I have found the answer to my problem listed in another thread. Thank you.
swestenzweiga at 2007-7-14 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...