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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:46:08+00:00 2026-05-29T04:46:08+00:00

iam having a jsp page Index.jsp which accept a only unicode string as its

  • 0

iam having a jsp page Index.jsp which accept a only unicode string as its parameter and submit the form to Result.jsp. I need to maintain the cookie for the string entered by the user each time user enter the new string cookie value would be changed i have wriiten following code

In Index.jsp i have crated the Cookie

<%
        Cookie ck= new Cookie("DNString",";");
        response.addCookie(ck);
%> 

and in the servlet i am trying to manage and set the cookie value each tim euser submits the form

private void fnSetCookieValues(HttpServletRequest request,HttpServletResponse response) 
    {

        Cookie[] cookies=request.getCookies();
        for (int i = 0; i < cookies.length; i++) {

            System.out.println(""+cookies.length+"Name"+cookies[i].getName());
            if(cookies[i].getName().equals("DNString"))
            {   
                System.out.println("Inside if:: "+cookies[i].getValue()+""+cookies.length);
                cookies[i].setValue(request.getParameter("txtIIDN"));
            }
        }

    }

but the problem is that while getCookie() it doesnt give the DNString as the cookie but only shows 1NameJSESSIONID as System.out.println(“”+cookies.length+”Name”+cookies[i].getName()); statement output

but while looking througn browser like

enter image description here
it shows DNString as a cookie stored

can anyone figure out the problem and possible solution for it.

Thanks

  • 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-05-29T04:46:09+00:00Added an answer on May 29, 2026 at 4:46 am

    The problem might be because of ; being the delimiter of cookie parameters.

    The value ";" added for the first time goes to the client with response header like this:

    HTTP/1.1 200 OK
    Server: tomcat
    Set-Cookie: DNSString=;;JSESSIONID=some-id-value
    ...
    ...
    

    The client sends back the cookie in the next request like this:

    GET /someurl Http/1.1
    Host: server.com
    Cookie: DNSString=;;JSESSIONID=some-id-value
    

    I think somewhere the parsing is failing because the value itself is delimiter.

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

Sidebar

Related Questions

I am having a JSP page, where i am dynamically creating a Table data.
I'm having some issues getting my pdf file to display in my jsp page.
I have a drop down in a jsp page having the following code <s:select
I'm trying to create a servlet which loads FirstJSP.jsp in WEB-INF/jsp/FirstJSP.jsp I'm having a
I am having trouble linking to a style sheet from a jsp page. I
I am having some frustrating javascript timing issues. FYI, the page is a jsp
I am having trouble with IE7. I have a header, which is an IMG.
I am having trouble integrating two products, one of which is mine and they
I am having a frequent problems with my web hosting (its shared) I am
I am having 2 pop up screens in my (Main) jsp. In the first

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.