Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7954073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:18:44+00:00 2026-06-04T03:18:44+00:00

In one servlet I have four variables. I want all those four variables to

  • 0

In one servlet I have four variables. I want all those four variables to be retrieved to another servlet.

I used the code in servlet 1 as follows.

import javax.servlet.http.HttpSession;


session.setAttribute("id",id);

In the other servlet I tried to get the value by using the code..

String id = HttpSession.getAttribute("id").toString();

I think there is a clear way to do the tracking of the session variables.

I have seen in net but all are confusing to me..

Please help me..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:18:45+00:00Added an answer on June 4, 2026 at 3:18 am

    First you need to get the Session object from the request.

    This is the HTTPServletRequest object sent to the servlet (you will have access to this in the doGet or doPost method).

    to set:

    ses = request.getSession(true);
    ses.setAttribute("Name","Value");
    

    to retrieve:

    request.getSession(false).getAttribute("name")
    

    getSession(true) means create session if one does not exist. getSession(false) is equal to getSession. Finally if you wish to remove the attribute from the session from that point you can use

    request.getSession().removeAttribute("Name");
    

    I hope this makes sense to you if you need more look at Java Set, Get and Remove Session Attributes.

    TomRed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect JSP page from one servlet. All JSP pages are under
I have login code in one servlet:LoginGtalkServlet.. XMPPConnection connection; //@see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
Until now I used to think that a web-application can have only one dispatcher-servlet
I have a servlet where I want when a user press one button, it
I have web application written in java using Eclipse. It has just one servlet
In servlet 3.0 one can use startAsync to put long work in another thread,
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
I am creating one application in which i am using jsp/servlet.. I want to
Possible Duplicate: Why is (javax.servlet.)SingleThreadModel deprecated? A servlet container generally create one instance of
I have a servlet that has a suspending method and a broadcasting one: @GET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.