Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


session menagement in servlets explaion briefly?



session menagement in servlets explaion briefly?..

Answer / abhijit dutta

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


public class SessionSample extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {


// Step 1: Get the Session object

boolean create = true;
HttpSession session = request.getSession(create);

// Step 2: Get the session data value


Integer ival = (Integer)
session.getAttribute ("sessiontest.counter");
if (ival == null) ival = new Integer (1);
else ival = new Integer (ival.intValue () +
1);
session.setAttribute ("sessiontest.counter",
ival);

// Step 3: Output the page

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Session Tracking
Test</title></head>");
out.println("<body>");
out.println("<h1>Session Tracking Test</h1>");
out.println ("You have hit this page " + ival + "
times" + "<br>");
out.println ("Your " + request.getHeader("Cookie"));
out.println("</body></html>");
}
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Struts Interview Questions

How do you know what to give for the "path " under in struts-config.xml ?

1 Answers  


What do you mean by the abstract package in struts2, and what is its utilization?

0 Answers  


What is apache struts used for?

0 Answers  


What is the purpose of @element annotation annotation?

0 Answers  


How to depoly your struts application in JBOSS

1 Answers   HP, NuWare, Satyam, Wipro,


what is the difference between model1 and model2 architecture in struts?

3 Answers  


What's mvc pattern ?

0 Answers  


What are the two different types of validations that the validator framework supports?

0 Answers  


What is MVC?

6 Answers   Infosys,


what is mean by custom tag?

5 Answers   Wipro,


wat happen when the connection is nt closed in jdbc n what vl happen when i interchange in executequery n execute statements

2 Answers  


What is the purpose of @customvalidator annotation?

0 Answers  


Categories