Java client posting to a servlet

Ads

 
 

Share on Google+Share on Google+

John
Java client posting to a servlet
1 Answer(s)      8 years ago
Posted in : Development process
Ads
View Answers

November 14, 2008 at 1:21 AM


Hi friend,

"getData.html"
<html>

<head>
<title>New Page 1</title>
</head>

<body>

<h2>Login</h2>
<p>Please enter your username and password</p>
<form method="GET" action="/htmlform/LoginServlet">
<p> Username <input type="text" name="username" size="20"></p>
<p> Password <input type="text" name="password" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
<p>&nbsp;</p>

</body>

</html>

"LoginServlet.java"

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = request.getParameter("username");
String pass = request.getParameter("password");
out.println("<html>");
out.println("<body>");
out.println("Thanks Mr." + " " + name + " " + "for visiting roseindia<br>" );
out.println("Now you can see your password : " + " " + pass + "<br>");
out.println("</body></html>");
}
}


web.xml file for this program:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">; -->

<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
</web-app>

For more information on servlets visit to :

http://roseindia.net/servlets/

Thanks

Ads









Related Tutorials/Questions & Answers:
Java client posting to a servlet - Development process
Java client posting to a servlet  Hi, I would like to create a java client that post to a servlet. I am trying to test out a webserver and would like to drive a number of connections using this process. Thanks  Hi
what is posting?
what is posting?  what is posting?   Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but not committing these transactions to the database
Advertisements
Posting Copy and Paste HTML
Posting Copy and Paste HTML   Posting Copy and Paste HTML
Java servlet
Java servlet  What is servlet
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
ssl client - JSP-Servlet
ssl client  How do you write SSL Client? Take example of SSL Socket Client
Java(Servlet) - Servlet Interview Questions
Java Servlet examples  Java and Servlet programming examples
Posting comments to same page with textarea
Posting comments to same page with textarea  I have been given some code which allows a user to type a comment and on submit it will return the text to the same page. Many thanks for that. However I wanted it to add other
Java servlet
Java servlet  What is the difference between an applet and a servlet
JAVA SERVLET - JSP-Servlet
JAVA SERVLET Log   Hi, A servlet file which create the log files ,then writing values to the list & log, we should have a thousand separator and no decimal values. This means instead of writing 986300.0 in the Log file
java servlet
java servlet   im using ubuntu 12.04 and ialready installed eclipse but i dont know how to run the servlet programs please give brief procedure to run the servlet program in eclipse
How to get client's address in a servlet
How to get client's address in a servlet       This is detailed java code to get client's address in a servlet. In this example we have used method getremoteAddr
JSP to client side - JSP-Servlet
JSP to client side  Hi I have a JSP(graph.jsp) page which calls a servlet and get the output. The output is a JSON object. I want to use the same to plot a graph in flotr. How can I use the same
Post Message In servlet
to the client . The servlet container creates a ServletResponse object and passes...Post Message In servlet       In this example, we are going to implement posting massage
Java Client Application
Java Client Application  Java Client Application
java servlet - JSP-Servlet
java servlet  hi friends, Thanks in advance. Am poornima am created new servlet in eclipse its open but without including any code am getting..., Put servlet-api.jar into the lib folder of apache tomcat server. Thanks
Java Servlet - JSP-Servlet
Java Servlet   Hello Sir Could you help me in understanding directory Structure for servlet page in eclipse (IDE). I save my Sevlet in WEB-INF but it is not displaying, it is displaying code of servlet. Process used
servlet prog - Java Interview Questions
servlet prog  how to forward or redirect the client request from servlet to jsp? how a thread or request pass from one servlet prog to one jsp prog? is it possible of communicating from servlet to jsp prog? please explain briefly
Java Client Application example
Java Client Application example  Java Client Application example
Java HTML Client Application
Java HTML Client Application  Java HTML Client Application
java servlet - Java Beginners
java servlet  how to use java servlet? and what the purpose of servlet?  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/ Hope that it will be helpful for you. Thanks
Java Servlet - JSP-Servlet
Java Servlet  3-tier structures of servlets
Java - JSP-Servlet
Java  Using Servlet,JSP,JDBC and XML How to create a web application... can create JSP/Servlet web application. http://www.roseindia.net/jsp.... Thanks for posting questions. RoseIndia Team
Sitemap Java Servlet Tutorial Section
Map | Business Software Services India Java Servlet Tutorial Section... | Snooping Headers | Dice Roller in Java Servlet | Getting Init Parameter... value Using Servlet | Hit Counter Servlet Java Servlet Tutorial Section
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets the ServletContextAttributeListener interface. I am overriding all three methods, but in the attributeReplaced() method, i want to perform a redirect to another servlet
java servlet programming - JSP-Servlet
java servlet programming  i want 2 insert the date time into the sql column of data type datetime through servlets dynamically .How 2 do dat
Java : What is servlet?
Java : What is servlet? This section define the concept of java servlet. Servlet : Servlets are small java programs run on web server. You can say... the Java Virtual Machine. Since the servlet runs on server side so it does
JAVA JSP and Servlet - JSP-Servlet
JAVA JSP and Servlet  for sending mail through lan without intenet and also chatting facility for online users using Java JSP & SERVLET code.  Hi Friend, Please visit the following links: http://www.roseindia.net
JAVA - JSP-Servlet
Java servlets sessions session tracking  How to track the session in Servlet
java - JSP-Servlet
java  why is required to write both jsp and servlet in a application of java
java servlet programming - JSP-Servlet
java servlet programming  when i m inserting an image file into the sql table in a column of data type binary using prepared statement ps.setBinaryStream, instead of filename it's displaying