dfischer.femtowebserver.test
Class InputFormTestWeblet
java.lang.Object
|
+--dfischer.femtowebserver.test.InputFormTestWeblet
- All Implemented Interfaces:
- HttpdWebletInterface
- public class InputFormTestWeblet
- extends java.lang.Object
- implements HttpdWebletInterface
This Weblet example displays a HTML input form. After the submit button
has been pressed, the input form result-data will be shown.
Sourcecode
package dfischer.femtowebserver.test;
import dfischer.femtowebserver.httpd.*;
public class InputFormTestWeblet implements HttpdWebletInterface
{
private static String COUNTRY[] = { "Colombia", "Switzerland", "Thailand" };
public void execute(HttpRequest req, HttpResponse res, HttpdProperties httpdProperties) throws Exception
{
res.println("<HTML>");
res.println("<BODY>");
String action = req.getParameter("action");
if (action == null)
{
// display input form
res.println("<FORM ACTION=\"" + req.getRequestFile() + "\" METHOD=POST>");
res.println("<INPUT TYPE=HIDDEN NAME=\"action\" value=\"1\">");
res.print("Coutry: <SELECT NAME=\"countryCode\" SIZE=\"1\">");
for (int x = 0; x < COUNTRY.length; x++)
res.print("<OPTION value=\"" + x + "\">" + COUNTRY[x]);
res.println("</SELECT> ");
res.println("Input Text: <INPUT TYPE=TEXT NAME=\"inputText\" SIZE=12 MAXLENGTH=12></> ");
res.println("<INPUT TYPE=SUBMIT VALUE=\"Submit\">");
res.println("</FORM>");
}
else
{
// display result of input
int countryCode = Integer.valueOf(req.getParameter("countryCode")).intValue();
res.println("The selected Country is <B>" + COUNTRY[countryCode] + "</B>.<BR>");
res.println("The Input Text is <B>\"" + req.getParameter("inputText") + "\"</B>.<P>");
res.println("<A HREF=\"" + req.getRequestFile() + "\">back to input form</A>");
}
res.println("</BODY>");
res.println("</HTML>");
}
}
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InputFormTestWeblet
public InputFormTestWeblet()
execute
public void execute(HttpRequest req,
HttpResponse res,
HttpdProperties httpdProperties)
throws java.lang.Exception
- Executes the Weblet.
- Specified by:
execute in interface HttpdWebletInterface
- Parameters:
req - HTTP request datares - HTTP response data of the WeblethttpdProperties - properties of the Femto Web Server