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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:34:56+00:00 2026-05-24T00:34:56+00:00

*//post method* protected void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException { String username

  • 0
*//post method*
protected void doPost (HttpServletRequest req, HttpServletResponse res)
        throws ServletException,IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password"); 
        System.out.println( " Form data recieved .. Now Verifying ");

        if ( loginVerificator ( username, password ) )  {
            Cookie xO = new Cookie ( "username", username );
            Cookie xT = new Cookie ( "password", password );            
            res.addCookie( xO );
            res.addCookie( xT );
            res.setContentType( "text/html" );
            PrintWriter out = res.getWriter( );
            out.println("<meta http-equiv=\"refresh\" content=\"2\";url=\"home\">");
        }

The post method retrieves the form parameters and then creates cookies from them and adds those cookies to the response. Then it redirects the page with meta tag.

I want to know why this page is reloading instead of redirecting. I am not able to find where I am making a mistake.

  • 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-24T00:34:58+00:00Added an answer on May 24, 2026 at 12:34 am

    out.println("<meta http-equiv=\"refresh\" content=\"2\";url=\"home\">");

    writes a meta tag in the response with the following value:

    <meta http-equiv="refresh" content="2";url="home"> which is incorrect, as the url is not wrapped by the quotes for the content attribute value. Instead the tag should have been generated as:

    <meta http-equiv="refresh" content="2;url=home"> which requires the corresponding line in the servlet to be:

    out.println("<meta http-equiv=\"refresh\" content=\"2;url=home\">");


    Note that the meta refresh concept has been deprecated by W3C. If you intend to redirect the user to a new page, it is always preferable to use a HTTP 302 response, which is easily doable in Servlets using the HttpServletResponse.sendRedirect(location) method.

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

Sidebar

Related Questions

For a POST method, the W3 specs say: If a resource has been created
I'm doing a Get and Post method for an android project and I need
What's the difference when using GET or POST method? Which one is more secure?
I am looking at the Moneris Payment Processing and their Direct Post method. For
My university doesn't support the POST cgi method (I know, it's crazy), and I
I have this function from a plugin (from a previous post) // This method
I have the following code which works just fine when the method is POST,
Suppose you have a method with some pre and post-conditions. Is it ok to
I'm using the AcceptVerbs method detailed in Scott Gu's Preview 5 blog post for
I have my resource and they typical overridden method to handle POST requests. public

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.