aspose file tools*
The moose likes Servlets and the fly likes HTML form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTML form" Watch "HTML form" New topic
Author

HTML form

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225

I tried to put two parameters from html form and get it to the servlet and then display it.

my servlet is located in C:\Tomcat\apache-tomcat-6.0.18\webapps\chapter1\WEB-INF\classes\LoginServlet.class

my html form is located in C:\Tomcat\apache-tomcat-6.0.18\webapps\name.html

i put html form action as <form method="GET" action="/chapter1/LoginServlet">


my web.xml file is as below .but when i put two parameters and click submit butten nothing happen .it should display what i entered.


<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>

</web-app>
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Classes ought to be placed in a package. Start with that.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
this is my name.html form




and this my servlet




there are no pacage statement but still not working?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

aruna sameera wrote:there are no pacage statement but still not working?


That's what Bauke is pointing out. Put your servlet into a package and then change the web.xml to reflect the complete i.e. fully qualified name of the servlet class...
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192
I had that same problem with my JSP page. It worked when I put my beans in a package.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
The reason is that if the JVM trys to load a class not in a package, it looks in the "current" directory. In the servlet environment you have no control over the "current" directory, therefore ALL classes used in servlets MUST be in packages to avoid strange errors.

Bill
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
There are environments wherein packageless servlets work (combination of certain appserver implementation/version and certain JVM implementation/version), but you should never make your application dependent on that. Put classes in packages, period. Only then the other classes can import them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML form