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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:25:43+00:00 2026-05-27T11:25:43+00:00

I have a java web application that uses form based authentication. If a standard

  • 0

I have a java web application that uses form based authentication. If a standard web user hits my site they are redirected to login.jsp, they submit their credentials and then the resource is given to them.

I have a simple java client that needs to post information to my web app on occasion. When my java client posts the information the server sends back login.jsp which I would expect. I can submit a second request to j_security_check with the credentials but any additional request I send still goes through as if I’m unauthenticated.

I know browsers store session information in the headers and transfer that back and froth to the server to help maintain state, but how do I do something similar from a java client so that subsequent requests are authenticated.

  • 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-27T11:25:44+00:00Added an answer on May 27, 2026 at 11:25 am

    This happens because you do not send cookies.

    When you turn to server first time it creates session for you. The session has ID. This ID is sent to client as special cookie, e.g. server sends HTTP header Set-Cookie. Typically java based servers use cookie named jsessionid but it actually does not matter. You at client side should get the value of response header Set-Cookie and send it back using HTTP header Cookie. In this case server will process your second and third (etc.) requests in context of the same session. Your second request (post of the login form) makes session authenticated, so you will not be redirected to the login form again and again.

    If you can configure the server side, you can do it easier. The server should be configured to support basic authentication too (additionally to form based authentication). So, your client can send header Authorization with value Basic USER:PASSWORD
    where USER & PASSWORD should be sent in Base64 form.

    EDIT: you can use Jakarta HttpClient. It simplifies everything when you are dealing with HTTP. But standard Java HttpURLConnection can do the job too.

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

Sidebar

Related Questions

We have a java web service application that uses log4j to do logging. An
I have a web based application that uses a self signed certificate. When you
I have a Java web application that uses a plugin architecture. I would like
We have a Java web application that uses Spring and Hibernate and has a
I have a Java web application that uses the SLF4J logging facade. To date,
I have a Flex/Java web application that uses Maven as a build tool. Currently,
I have a web based application that uses userName and password for login. now
We have a desktop application written in Java Swing that currently uses Java Web
I have a java web application running on WebSphere 7. The application uses form
I have a Java web application that currently uses Log4J for logging. I'd like

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.