Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Servlet Question

  Asked By: Emily    Date: Sep 22    Category: Java    Views: 486
  

Have a simple servlet question. I got an error message when testing
Hello servlet. I am attaching the code it is from a text book. I am
using IIS and compliled the java code to generate class files using
sunOne studio. The HTML file is not connecting to the servlet. Could
you please let me know.
<HTML>
<HEAD>
<TITLE>Introductions</TITLE>
</HEAD>
<BODY>
<FORM METHOD=GET ACTION="/servlet/Hello">
If you don't mind me asking, what is your name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Hello extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();

String name = req.getParameter("name");
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>");
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
}

public String getServletInfo() {
return "A servlet that knows the name of the person to whom
it's" +
"saying hello";
}
}

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Emily Brown     Answered On: Sep 22

I am using IIS and trying to connect from a HTML Page to a servlet.
HTML page is unable to connect to the servlet. Could somebody help
me with that.

 
Answer #2    Answered By: Jarrod Williams     Answered On: Sep 22

To connect to a servlet, you need a servlet  engine. You can download the
TomCat servlet engine from this link:

http://jakarta.apache.org/tomcat/index.html

It's a servlet engine that works under many web servers including the IIS.

 
Answer #3    Answered By: Evelyn Hughes     Answered On: Sep 22

put the java code  in <% %> and then try again..


 
Answer #4    Answered By: Douglas Sullivan     Answered On: Sep 22

could you please tell us what is error  message displayed so that it
would be easy to identify

 
Didn't find what you were looking for? Find more on Servlet Question Or get search suggestion and latest updates.




Tagged: