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 8872625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:15:49+00:00 2026-06-14T18:15:49+00:00

I have a web application which uses a filter servlet to create session, but

  • 0

I have a web application which uses a filter servlet to create session, but I have such problem with session as below:

url1: localhost:8080/home.html

url2: localhost:8080/user/1.html

If the user access the url1 first, it will create a session, and if user navigation to url2. it will not create second session.

But if user access the url2 first, it will create a session, and if user navigation to url2. it will create second new session.

What’s wrong with it?

It looks it creates one JSESSIONID cookie for / and another for /user if user access url2 first.

My code is here:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException  {
String errorMsg = null;
if (request instanceof HttpServletRequest && response instanceof HttpServletResponse)
{
  final HttpServletRequest httpRequest = (HttpServletRequest) request;
  final HttpServletResponse httpResponse = (HttpServletResponse) response;
  httpRequest.setCharacterEncoding("UTF-8");
  HttpSession httpSession = httpRequest.getSession(false);
  String path = httpRequest.getServletPath();

  if ("/login.htm".equals(path)){
       String mail = httpRequest.getParameter("mail");
      String password = httpRequest.getParameter("password"); 

      if ((!Utils.isNull(mail)) && (!Utils.isNull(password)))
      {
        UserDTO dto = new UserDTO();
        dto.setPassword(password);
        dto.setMail(mail);
        dto = is.loginValidate(dto);

        if(dto!=null){
            dto.setClientid(httpRequest.getHeader("User-Agent") + httpRequest.getRemoteAddr());
            httpSession.setAttribute("system.userinfo", dto);
            is.saveLastLoginDate(httpRequest);
        }
      }
  }else{
      if(httpSession==null){
          httpSession = httpRequest.getSession(true);
      }
      Object obj = httpSession.getAttribute("system.userinfo");
      if(obj==null){
        UserDTO dto = new UserDTO();
        dto.setUid(GUESTID);
        dto.setClientid(httpRequest.getHeader("User-Agent") + httpRequest.getRemoteAddr());
        httpSession.setAttribute("system.userinfo", dto);
      }
  }
  • 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-14T18:15:51+00:00Added an answer on June 14, 2026 at 6:15 pm

    it looks it’s an environment issue, if i change another pc, the problem went away

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

Sidebar

Related Questions

I have a problem with a little .Net web application which uses the Amazon
I have a web application code which uses jsp, servlet and ejb. I created
I have a web application which uses the globalization values being passed from sql
Suppose I have a web application, which uses jQuery for Ajax and UI. Now
I have a web application that uses a library which resides in TOMCAT_HOME/common/lib. This
I have a currency converter application for iphone which uses web service. The web
I have a web-application which uses hibernate and for some reason every thread (httprequest
I have a web application which uses membership and profiles. I successfully used the
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I am using VS2005 ASP.NET 2.0. I have a web application which uses Active

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.