Java client posting to a servlet

Java client posting to a servlet

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









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) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
Java servlet
Java servlet  What is servlet
data scientist job posting
data scientist job posting  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data scientist job posting Try to provide me good examples or tutorials links so that I can
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) - Servlet Interview Questions
Java Servlet examples  Java and Servlet programming examples
Post Message In servlet
a response to the client . The servlet container creates a ServletResponse object...Post Message In servlet       In this example, we are going to implement posting massage
ssl client - JSP-Servlet
ssl client  How do you write SSL Client? Take example of SSL Socket Client
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
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
Java servlet
Java servlet  What is the difference between an applet and a servlet
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
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
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
How to get client's address in a servlet
How to get client's address in a servlet  ... client's address in a servlet. In this example we have used method getremoteAddr... to a servlet that execute the request and find the ID address of the client's request
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 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
Guest Posting Tutorial - Getting Started with Guest Posting
Guest Posting Tutorial - Complete Tutorial of Guest Posting and Guest... Posting or Guest Blogging. We will keep updating our tutorials to keep track... Blogging. Guest Posting is also known as Guest Blogging and these two terms
Java Servlet - JSP-Servlet
Java Servlet  3-tier structures of servlets
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 - 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 ADS_TO_REPLACE_1 Java Servlet
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 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
JSP with java/servlet - JSP-Servlet
(java bean or servlet) to fecth the database. Jsp would get the data from...JSP with java/servlet  Thanks Deepak for your answere to my previous.../servlet-jsp-data-list.shtml Hope that it will be helpful for you. Thanks
Java Servlet - Servlet Interview Questions
Java Servlet  My Servlet Program is generating Compile time errors. 1)pakage javax.Servlte.Http.* does not exists. and Pakage javax.Servlte does... be that you have not set the classpath of your java-servlet-api.jar in the environment
java servlet code - Servlet Interview Questions
java servlet code  iam doing a project in java, preparation of on line examination in that how to prepare a question paper using servlet code
java,servlet,jsp - JSP-Servlet
java,servlet,jsp   i am doing a project on online examination system and in that there are problems that-- 1.i want to disable the back,forward and refresh button.Please give me the code for google crome browser. 2.suppose
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... entirely inside the Java Virtual Machine. Since the servlet runs on server side
Best Guest posting services in 2022
Best Guest Posting Services in 2022 - Get most from Guest Posting /Guest Blogging in 2022 Guest Posting or Guest Blogging is one of the most popular and awarding off-page SEO techniques in 2022. Companies are using guest posting
Best Guest posting services in 2022
Best Guest Posting Services in 2022 - Get most from Guest Posting /Guest Blogging in 2022 Guest Posting or Guest Blogging is one of the most popular and awarding off-page SEO techniques in 2022. Companies are using guest posting
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 - 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 - JSP-Servlet
Java Servlet Config means   What is Servlet Config means ?  ...://www.roseindia.net/servlets/ServletContext.shtml  Servlet Config means configurion of servlet it is used to cofigure any properties in web.xml and Context
Java Servlet
Java Servlet  how to create the login form using servlets and how to validate the username and password?   Please visit the following link: http://www.roseindia.net/jsp/loginbean.shtml
java servlet compilation error - Servlet Interview Questions
java servlet compilation error  i done the Restart your tomcat server and run your servlet.but i got the problam
java servlet compilation error - Servlet Interview Questions
java servlet compilation error  hello sir plz help me, i compile the servlet program but i got the arrors that errors are package javax.servlet.http..., Put servlet-api.jar into the lib folder of apache-tomcat.And set the class path
java servlet help neeed....
java servlet help neeed....  i have little bit miss concept on servlet and jsp....what ever i know always the jsp provoke first then servlet ...like... the servlet will be called (mapping i have to make in web.xml)......but to some one told
Java script in servlet
Java script in servlet  Hi. How to use javascript inside java servlet? Thanks in advance
servlet
of the Servlet API. It contains the classes necessary for a standard, protocol-independent servlet. Every servlet must implement the Servlet interface in one... that communicate with the server and the client
Instant Approval Guest Posting Websites
Instant approval Guest posting - Websites for instant approval of the guest posts Are you looking for the Instant approval guest posting websites having high DA and good amount of traffic for posting your next guest post? Then you
java servlet - Servlet Interview Questions
java servlet   i use tomcat server and eclipse as ide for j2ee environment when i tries the example for sevlet context in roseindia to make entry in server log file ( context.log method to log entry) but could not see the log
Java - JSP-Servlet
cmd + (Enter Key) 2. Change the directory to the Servlet file(i.e .java) and 3...Java  What a the steps to compile a Servlet Programe.  Hi... to configure tomcat for running servlet. http://www.roseindia.net/servlets
java charts - JSP-Servlet
java charts  Hi,can any one tell me how to create dyanamic charts wrt database contents by using jsp-servlet
Java Servlet - Development process
Java Servlet  Hello Sir how to set Classpath for Java Servlet.  Hi Friend, Put servlet-api.jar file into the lib folder of apache...:\apache-tomcat-6.0.16\lib\servlet-api.jar For more information, visit
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program
java server programming : servlet - JSP-Servlet
java server programming : servlet  hi all, can you help check what's wrong with my servlet that i have a null pointer exception.Thanks ERROR... servlet request * @param response servlet response */ protected

Ads