Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shaziya
web-design
2 Answer(s)      6 years and 2 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

August 8, 2008 at 5:53 PM


Hi



package javacode;

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

public class GetSession extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session = req.getSession(true);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String title = "Searching the Web";
String heading;
Integer count = new Integer(0);;
if(session.isNew()) {
heading = "Welcome, To GetID";
}
else {
heading = "Welcome Back";
Integer oldcount = (Integer)session.getValue("count");
if (oldcount != null) {
count = new Integer(oldcount.intValue() + 1);
}
}
session.putValue("count", count);
out.println(ServletValue.headWithTitle(title) +
"<body BGCOLOR=\"pink\">\n" +
"<h1 ALIGN=\"CENTER\">" + heading + "</h1>\n" +
"<center><H2>Information on Your Session:</H2></center>\n" +
"<TABLE BORDER=1 ALIGN=CENTER>\n" +
"<tr BGCOLOR=\"green\">\n" +
" <TH>Info Type<TH>Value\n" +
"<tr>\n" +
" <td><b>ID</b>\n" +
" <td>" + session.getId() + "\n" +
"<tr>\n" +
" <td><b>Creation Time</b>\n" +
" <td>" + new Date(session.getCreationTime()) + "\n" +
"<tr>\n" +
" <td><b>Time of Last Access</b>\n" +
" <td>" + new Date(session.getLastAccessedTime()) + "\n" +
"<tr>\n" +
" <td><b>Number of Previous Accesses</b>\n" +
" <td>" + count + "\n" +
"</table>\n" +
"</body></html>");

}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}


August 8, 2008 at 5:55 PM


web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>



<web-app xmlns="http://java.sun.com/xml/ns/javaee";

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";

version="2.5">



<description>

Servlet and JSP Examples.

</description>

<display-name>Servlet and JSP Examples</display-name>
<servlet>
<servlet-name>getsession</servlet-name>
<servlet-class>javacode.GetSession</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getsession</servlet-name>
<url-pattern>/jsp/GetSession</url-pattern>
</servlet-mapping>
</web-app>

------------------------------------------------

Read for more information.

http://www.roseindia.net/servlets/

Thanks.


Related Tutorials/Questions & Answers:
web design
web design   Hii.. I have to design one registration page in java... (here i have to design captcha) submit (while clicking on submit... design that. Please help me asap Thanks a lot
Web design program - WebSevices
Web design program  Design an HTML page to create the standard calculator. When user will click on the button, display the caption of selected button in new document
Advertisements
Web Design Training
Web Design Training  Hi, How to learn Web Design? What is the best courses in Web Design Training? Thanks   Hi, These days websites... design in PSD format, maintaining the websites etc. As a web designer you should
Web design program - WebSevices
Web design program  Design an HTML page to accept Name (text box), Address (multiline textbox), Gender (radio button), Qualification (single selection), Specialisation (multiple selection), Languages (checkbox), Submit
Web design program - WebSevices
Web design program  Create the .css file. Write different styles for table cell to assign background colour. Incorporate the style in .html file. Create a table of 4 rows, 2 columns in the .html file. Using style, change
Web design program - WebSevices
Web design program  Accept any two numbers using text box. Provide four buttons Add, Divide, Square, and Modulus (remainder of division). On clicking corresponding button, display the relevant result in new window.  
Web design program - WebSevices
Web design program  Design an HTML page to accept information of the employee (important 5 details). Use appropriate controls. Give title ‚... controls using horizontal line. Design the web page with relevant background image
Web design program - WebSevices
Web design program  Create a dynamic page using CSS as follows. a) The text displayed using should have background color ‚??Brown‚?? and text color ‚??white‚??, font ‚?? Arial. (2 marks) b) The paragraph can be displayed
Web design program - WebSevices
Web design program  Provide two links. Display an image in new document on clicking corresponding link. The image displayed using second link should have 3 links to open 3 different files. Note : Each image should have border
web-design - JSP-Servlet
web-design  hi, i wanted to know what is web design.. is it the servlet that we write producing the output on the web page????????  Hi... out = res.getWriter(); String title = "Searching the Web"; String heading
what is php used for in web design
what is php used for in web design  what is php used for in web design
WEB Design
WEB Design  Write a program to open the link in first frame in another frame?   Please visit the following link: Webservices Tutorials
Web design company in Delhi
Web design company in Delhi We are professional web design and development... design premium templates for your online website and web portals...; Cafe and Restaurant We design website and web applications
What are Web Design Services
What are Web Design Services The term web design looks simple that refers to arranging contents... of the customer. A perfect web design service not only enhance the traffic
Top 10 Web Design Tools
of people accessing the web on their handheld device, web design is no more... across the devices. The task of choosing top 10 web design tools is no longer... on handheld devices. In choosing the best web design tools we have nevertheless
Top 10 Web Design Mistakes
Blaming the web design mistakes is a common behavior when a website faces... aspects is lost. There are many philosophies on classifying the web design mistakes... design mistakes nothing is as severe as presenting the content in back foot. Web
10 Common Web Design Mistakes
10 Common Web Design Mistakes Designing a website is the most crucial part... of business deliverables and outcomes. Web design is no more of just ornamental... discussion on top 10 common web design mistakes we must understand the effectiveness
Professional Web Design Services For You Web Site
Professional Web Design Services For You Web Site  ... design of the web site.... However there are also some guidelines to the use of graphics on the web
web design - WebSevices
web design  I want to use macromedia Dreamweaver for designing the web pages for my j2ee web application, But i do not know how to use Dreamweaver so please help me. Thanks
web design - WebSevices
web design  I want to use macromedia Dreamweaver for designing the web pages for my j2ee web application, But i do not know how to use Dreamweaver so please help me. Thanks
Top 10 Web Design Trends
Top 10 Web Design Trends Website design is no more is just about looks... web design trends tend to evolve with change in technology and user interface... and appreciation, there have been different philosophies of web design that continued
Top 10 Web Design Principles to Follow
Top 10 Web Design Principles to Follow Usefulness, utility and responsiveness... the effectiveness of your web presence. Web design principles mainly focus on how you can better create an interactive space for your audience or users. Web design trends
Web Design Packages, Website Design Packages
an extensive range of web design solutions for all, from individuals to corporate...: HTML Basic Web Design Packages HTML Basic + Web Design Packages HTML Silver Web Design Packages
web design - Design concepts & design patterns
web design  hello sir. my quesstion is same please guide me. please reply my question .because it very urgrent. I want make header like-http://www.sigmainfotech.com.au/ this site but in this site header make in flash, I
Web Design Portfolio
Web Design Portfolio The Roseindia?s Web Designer develops Website... of the web design meets the web standard parameters. Followings are the guidelines that we follow while web design are: Usability Consistency Simplicity
Animated Web Design
Animated Web Design Animation needs the higher skill of work and experience, and animation on web not only need the art but also need the technical skills... Web page design optimization Graphic design Presentations
Corporate Web Design Services
Corporate Web Design Services The corporate website is an informative website that is operated by a business company and provides comprehensive information... and business. Contact to us to our specialist corporate web designers to create
What is E-Commerce Web Design
What is E-Commerce Web Design...’s e-commerce design solutions. Our e-commerce web design comes..., around the corner or around the world using our professional Web design
Web Design Packages, Website Design Packages
design Standard/Custom Shopping cart web design Graphics/ Flash...' and enjoy the advantage of perfect custom business web design solutions... Custom Website Design for Business Custom Website Design has become one
Web Development Services,Web Design Development Services,Website Developement Services India
Web Development Services RoseIndia.net is a specialize software firms.../server platform as well as web domain. First of all we do study and understand... information system to fulfill the requirements and design desired by the customer
Fashion Web Templates
, Croquis. The Fashion Design web templates are available in different sizes and types... templates or Fashion Flash Web designing Templates? We offer creative fashion web design templates for Models, Designers, Fashion Magazines and Modeling agencies
 

 

 

DMCA.com