Home Answers Viewqa JSP-Servlet web application

 
 


Gowrishankar
web application
1 Answer(s)      2 years and 6 months ago
Posted in : JSP-Servlet

Develop a web application to print back the inputs from the user(name, date of birth, address). The solution should have a JSP file which accepts the userâ??s name and sent to Servlets which puts the name in the session and which should be forwarded to another servlet / JSP, which shall print the same back to the user from the session.

Tomcat is available in http://localhost:8080 user : admin/password : admin We are keen on coding standards (comments, class/ method/ variable naming convention etc.)

View Answers

December 15, 2010 at 1:34 PM


Hi Friend,

Try the following code:

1)form1.jsp:

<html>
<form method="post" action="../GetServlet">
<table>
<tr><td>Enter Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="submit" value="submit"></td></tr>
</table>
</form>
</html>

2)GetServlet.java:

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

public class GetServlet extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        String name=req.getParameter("name");
        String address=req.getParameter("address");
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        HttpSession session= req.getSession();
        session.setAttribute("sname", name);
        session.setAttribute("saddress", address);
        RequestDispatcher dispatcher = req.getRequestDispatcher("/jsp/form2.jsp");
       if (dispatcher != null){
        dispatcher.forward(req, res);
      } 
        }
        }

3)form2.jsp:

<%
String name= (String)session.getAttribute("sname");
String address=(String)session.getAttribute("saddress");
%>
<html>
<form>
<table>
<tr><td>Your Name is:</td><td><input type="text" value="<%=name%>"></td></tr>
<tr><td>Your Address is:</td><td><input type="text" value="<%=address%>"></td></tr>
</table>
</form>
</html>

Thanks









Related Pages:
web application
web application  what is lazy loading in web based application
web application
web application  Dear friend, could u plz tell me wats difference bt web server,application server,container with thanks praveen
Web application
Web application  in web applications which file will execute first either servlet or jsp
web application
web application  Develop a web application to print back the inputs from the user(name, date of birth, address). The solution should have a JSP file which accepts the userâ??s name and sent to Servlets which puts the name
web application to internet - JavaMail
web application to internet  how to connect my web application to internet
web application - WebSevices
web application  how to create a j2ee web application using java abstract class & interface
connecting to timesten in web application
connecting to timesten in web application  Please give me the steps connecting to timesten in web application. Am using jsp
Web application security - Security
Web application security  Hi, Expert how to hide url in webpage or fix the url in every web page in java.Please give any suggestion or idea
Directory structure of a web application
Directory structure of a web application   Explain the directory structure of a web application.    The directory structure of a web application consists of two parts. A private directory called WEB-INF. A public
Web application - Spring
Web application  I need one simple complete web application example using springs with database connection,i saw ur demo but it is not succfient.can u send to raghavendra@oneapps.com.I am a beginner
java web application - Ant
tell me the steps to build and deploy a small web application on MyEclipse?(like... a directory structure for a Web application. a)Create a WEB-INF directory... deployment descriptor in the WEB-INF directory for the Web application. 5
log4j in web application
log4j in web application  Hi all, I am new to log4j. I want to use log4j in my web application. I need to write the debug,info,warn into a file... and how to get the logger object in web application. Thanks suresh
Java web Application
Java web Application  Hi! I have developed a java web application project using netbean IDE with glassfish server. My question is how to create a runnable file from this. How can we make it to a single file? I think it is war
Quartz in web-application
Quartz in web-application  As I am new to Quartz i don't know how to use it in web-application.I am able to run it in eclipse as a stand alone application i had tried out some example but am not able to succeed any help
Web
Web  Application is not working in any versions of IE. Its working good in firefox. Please help me.. Thanks in advance
Flex web application
Flex web application  Hi.... How can i develop web based applications in Flex? please give me the whole procedure so i can make web apps in flex..... Thanks
Web application - business layer
Web application - business layer   Design your business layer to be stateless, which helps to reduce resource contention and increase... with a stateless Web application business layer. If you perform business
what is the difference between distributed application and web application?
what is the difference between distributed application and web application?  what is the difference between distributed application and web application
Web Application Common Architecture
Web Application Common Architecture  Hi, Any one tell me, while project constructing , how they architect it which means using some layers and specify importance of layers. And also best way to follow program flow
servlet question on web application
servlet question on web application   how to write a programg on the web application. create two modules like admin and customer. customer can registrate with user id and password. after finishing of his registration he'll get
draw chart in web application
draw chart in web application  how to draw bar chat from the record store in database? i.e. draw the bar chart according to selected record
Web application - JSP-Servlet
Web application   Helo can you please help me in knowing how to use jsp/servlets which allows users to post question in a forum so that other users can also view the question and respond to it.For instance your application here
web application security - Security
web application security  Hello, Experts how can i prevent that a copy url cannot run in same brower or different browser again .Please Suggest any idea i already check if a session is null then forwward a login page
error in web application
error in web application  In your application when i am trying to execute it from the below page <%@ page language="java" import="java.util....; We are providing you another application. Check it. 1)application.jsp
php mysql web application tutorial
php mysql web application tutorial  How to create a simple php mysql web application? Please post an example or tutorial
HTS Web Application Framework
HTS Web Application Framework       The HTS Web Application Framework is a PHP and Javascript based framework designed to make simple web applications easy to design and implement
Web application? - Java Interview Questions
Web application?  What is webapplication?  Hi friend, Any application that uses Web Technologies including web browsers, web servers and Internet protocols is called Web Application. A web application can
To publish jsp web application in intranet
To publish jsp web application in intranet  I am making web application in jsp with netbean. I want to publish this web application in LAN/Intranet.So by publishing web application it can be access through LAN/Intranet
ssl comunication between a desktop application and a web application
ssl comunication between a desktop application and a web application  Hi Lusiano, I am trying to implement a ssl comunication between a desktop application and a web application. can you please share code with me. Please
Why Struts in web Application - Struts
Why Struts in web Application  Hi Friends, why struts introduced in to web application. Plz dont send any links . Need main reason for implementing struts. Thanks Prakash
creating a friendly url for web application
creating a friendly url for web application  Hi all, I don't know how to create a friendly url for a web application. Please help me to resolve this problem. Thanks, Suresh
Quartz web application - Java Beginners
Quartz web application  Quartz is not firing jobs as per cron expression in java web application. I set the cron expression as 0/20 * * * * ? and when i load the web application it runs fine but its not firing the job after
Introduction of Web Application
The application based on web is stored on a remote server and they can be accessed through web browser
Application Server and Web Server - WebSevices
Application Server and Web Server  General difference, Application Server and Web Server  Answer: A Web server handles the HTTP protocol. When the Web server receives an HTTP request, it responds with an HTTP response
Web based workflow application example?
Web based workflow application example?  Hello there, Can anyone please send a sample project which is a web-based java workflow application? If it is built using Spring, Struts or JSF Framework it would be wonderful. If you
java web application printing - WebSevices
java web application printing  i have a web-page with a table displayed containing report card of a class of students(visual web JSF APPLICATION created in netbeans 6.0) d problm i hv is i wnt to let dat page be converted
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
DIFFERENCE BETWEEN APPLICATION SERVER AND WEB SERVER
DIFFERENCE BETWEEN APPLICATION SERVER AND WEB SERVER  What is the difference between application server and web server
create web application using maven
In this section, you will learn to create a web application using maven
Web Application Development,Web Application Development India
Web Application Development Solutions India Web Application Development... of internet services worldwide and greater reliability on custom web application... web application development solutions that are reliable, scalable and robust
Web Application Development in India, Web Application Development
Web Application Development in India Develop your Web Applications in India... customised web application development services to you. With our industry..., MySQL, ASP, PHP, etc our web application development services are always tuned
how to launch a web application using java web start in netbeans ide?
how to launch a web application using java web start in netbeans ide?  Hi RoseIndia, I need to launch my web application(web pages-jsp) using java... that java application(java classes) can be launched using java web start quit easily