html form not rendering in java servlet

McCoyHawkins

New Member
I am doing a very simple tutorial to learn java servlet programming. For some reason, the browser is not rendering the submit button in the html form that I am writing while doing the tutorial in eclipse. I have checked the code many times, including trying many small changes and even googling to confirm that I did in fact remember my basic html. But the problem persists.Specifically, when I run SimpleForm.html on my local Tomcat server from within eclipse, it renders the userName input box, but then it just outputs text versions of all the html code after that, starting with the input tag for the submit button.Here is the information required to recreate my problem. Can anyone show me how to fix this?The tutorial is at this link, about nine and a half minutes into it: http://www.youtube.com/watch?v=MnUJl3NYRRc&feature=endscreen&NR=1There are three files open in eclipse, including:web.xml\[code\]<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>SimpleServletProject</display-name> <servlet> <servlet-name>xmlServlet</servlet-name> <servlet-class>org.koushik.javabrains.XmlServlet</servlet-class></servlet><servlet-mapping> <servlet-name>xmlServlet</servlet-name> <url-pattern>/xmlServletpath</url-pattern></servlet-mapping></web-app>\[/code\]XmlServlet.java\[code\]package org.koushik.javabrains;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class XmlServlet extends HttpServlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String userName = request.getParameter("userName"); out.println("Hello! "+ userName); } }\[/code\]SimpleForm.html\[code\]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body> <form action='xmlServletPath'> <input name='userName' /> <input type='submit' /> </form></body></html>\[/code\]
 
Back
Top