I have installed on my computer a Tomcat web server 4.2; (properly
configured; because i could view .html, .jsp and .class files in the
webapp/ROOT/.. folder).
I want to create my own context root - i made one called "params"
in the "webapp" directory of my Tomcate installation, created two
subdirectly underneath (/params/WEB-INF and /params/ servlets) i
placed my "MakingGet.html" file in /params/servlets/ placed
my "web.xml" file in /params/WEB-INF and place my class
file "MakingGet.class" in directory /params/WEB-INF/classes/.
I have two problem
1. when i load the webpage with
http://localhost/params/servlets/MakingGet.html the page loads but
If i click submit the button doesn't do anything. (this is the most
disturbing). i have tried to put the complete url in the action
attribute of the form but it just didn't work.
I have attempted to run the class in /webapp/ROOT/WEB-INF/classes
using http://localhost//servlets/MakingGet and it showed that the
class is working fine; the class still did not load from the web
page (when i clicked submit) even when i put the complet url in the
action attribute of the form (i.e
http://localhost//servlets/MakingGet)
2. I have an alias i defined in my web.xml file called " paraform".
when i try to load using http://localhost/params/paraform, the page
didn't load.
I have stopped and restarted the webserver a million time without
any change.Please help me out; i have been on it for two days now.
This is my web.xml code
<?xml version="1.0" encoding="UTF-8">
<!DOCTYPE web-app PUBLIC "-//Sun Microsystem Inc.//DTD Web
Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>
Jeslob Anyware Java Server Page Test
</display-name>
<description>
This program test the use of three parameters
sent to the server machine.
<description>
<servlet>
<servlet-name> paraform</servlet-name>
<description>
"paraform" is the servlet alias while the
class name is MakingGet
<description>
<servlet-class> MakingGet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> paraform <servlet-name>
<url-pattern> /paraform <url-pattern>
</servlet-mapping>
</web-app>
<!DOCTYPE HTML PUBLIC "-//W3C// DTD HTML 4.0 Transitional //EN">
<html>
<head>
<title> Collecting Three Parameter</title>
</head>
<h1 align="center"> Music Collection Extractor </h1>
<hr>
<form action="/params/paraform" method="get" >
Album title <input type="text" name="param1"> <p>
Album Category <input type="text" name ="param2"> <p>
Artist Name<input type="text" name="param3"> <p>
<input type="button" value="SUBMIT">
</form>
</html>
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MakingGet extends HttpServlet{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out= response.getWriter();
String title= "Music Collection Extractor";
out.println(title);
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD
HTML 4.0 Transitional //EN \">");
out.println("<html><head><title>" +title
+ "</title></head> out.println("<h1 align=center>"+
title + "</h1> \n");
out.println("<ul> \n");
out.println("<li> Param1 </li>"+
request.getParameter
("param1") + "\n"+
"<li> Param2 </li>"+
request.getParameter
("param2") + "\n"+
"<li> Param3 </li>"+
request.getParameter
("param3") + "\n"+
"</ul> \n"+
"
}
}