answersLogoWhite

0

How do you track a session in servlets?

Updated: 8/19/2019
User Avatar

Wiki User

∙ 13y ago

Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: How do you track a session in servlets?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Set and get session attributes syntax in servlets and java script?

Setting and getting session attributes is fairly easy. It is the same in both Servlets and JSPs with one exception. In a JSP, you already have access to the session object, and you do not have to declare it. In a Servlet, you must get the session like this: javax.servlet.http.HttpSession session = request.getSession(); Once you have done that, you can set a session object like this: session.setAttribute("name","value"); To retrieve the value, do this: String foo = (String) session.getAttribute("name"); A couple of things to keep in mind: * The second parameter in the setAttribute method is an Object, not a String. When you retrieve the value, you have to cast it. In the example above, I am casting it to a String. * If you try to perform a getAttribute on a session attribute that does not exist, or was not set, it will return a null. * Session attributes are not available using JavaScript. You can not set or get an attribute in JavaScript. * You do NOT need to do the 'session = request.getSession() in a JSP. It is only necessary in a Servlet.


Is it mandatory to learn servlets before JSP?

No. But, knowledge of Servlets would be an added advantage if you are learning JSPs


How can you display all the session variables in an HTML page?

HTML is a static language and hence access to Sessions is not available in HTML pages. Sessions are accessible only for J2EE systems that use Servlets, JSP etc.


Is it true that applets are more secure than servlets?

No. I believe, servlets are much secure and more powerful than applets.


Is j2ee servlet development kit useful for developing servlets in j2se?

J2SE stands for Java 2 Standard Edition and I dont think Servlets are a part of it. Servlets are only part of the Java 2 Enterprise Edition.


How are jsps betten than servlets?

JSPs can contain HTML, JavaScript, XML and Java Code whereas Servlets can contain only Java Code, making JSPs more flexible and powerful than Servlets. However, Servlets have their own place in a J2EE application and cannot be ignored altogether. They have their strengths too which cannot be overseen.


Can you use jsp and servlets together?

Yes. They are both used almost always together. In fact JSPs get converted to Servlets at the time of execution


Can you create web forums using jsp and servlets?

Yes. All sorts of web Applications/websites can be created using JSP and Servlets


How can you learn Servlets and Jsps in an easy way?

Try the Head First JSP & Servlets book. It is a good book for learning them. You can also try the internet. You can get a lot of websites that give you tutorials on JSPs and Servlets. One of them is available in the related links section


How you can display servlet page in jsp page?

You cannot. You display JSP Pages using the help of Servlets. Servlets are of the background classes and you cannot display them


What are the applications of servlets?

Servlet is a Server side component, a servlet is a small pluggable extension to the server and servlets are used to extend the functionality of the java enabled server.


What is servlet and why it is used?

servlet is a small program which run on serverside,and it can not be downloaded at client side. java servlets dynamically extends the functionalities of a web server. main use is: session tracking: no of users (unique) visited u'r website. in order to use cookies..