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

  • Home
  • SEARCH
  • 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 7866163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:18:38+00:00 2026-06-03T00:18:38+00:00

I have a very simple log-in servlet with the following code: userName = request.getParameter(username);

  • 0

I have a very simple log-in servlet with the following code:

            userName = request.getParameter("username");
    password = request.getParameter("password");

    if ("xxx".equals(userName) && "xxx".equals(password)) {
        RequestDispatcher requestDisSecure = request
                .getRequestDispatcher("VendorList_Secure.jsp");
        requestDisSecure.forward(request, response);
    }
    if ("xxx".equals(userName) && "xxx".equals(password)) {
        RequestDispatcher requestDisSecure = request
                .getRequestDispatcher("VendorList_Secure.jsp");
        requestDisSecure.forward(request, response);
    }
    if ("xxx".equals(userName) && "xxx".equals(password)) {
        RequestDispatcher requestDisSecure = request
                .getRequestDispatcher("VendorList_Secure.jsp");
        requestDisSecure.forward(request, response);
    }
    if ("xxx".equals(userName) && "xxx".equals(password)) {
        RequestDispatcher requestDisSecure = request
                .getRequestDispatcher("VendorList_Secure.jsp");
        requestDisSecure.forward(request, response);
    } else {
        /**
         * Unauthenticated user
         */
        RequestDispatcher requestDisUnSecure = request
                .getRequestDispatcher("VendorLoginError.jsp");
        requestDisUnSecure.forward(request, response);
    }

We come to this servlet logic from VendorLogin.jsp that has username & password parameter, if the login is correct it forward fine to the VendorList_Secure.jsp, but if not it will forward to VendorLoginError.jsp, but after inputting a new username & password and hitting the above servlet, i got both username & password parameters as null instead of the new updated values in the servlet!

I tried redirect instead, but i got the same effect

I know i could do much better with how to implement login through securing the resources in web.xml, but i want to know why this simple example doesn’t work

So what i am doing wrong here?

Many 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-06-03T00:18:39+00:00Added an answer on June 3, 2026 at 12:18 am

    your form elements should match the names given in getParameter.

    userName = request.getParameter("username");
    password = request.getParameter("password");
    

    that is like below

    <input type="text" name="username"  />
    <input type="password" name="password"  />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a very simple application tha accepts batches of telemetry log rows
I have some very simple javascript code that looks like this: var newWindow =
I have this very simple code: #include <stdio.h> #include <stdlib.h> int maxArr(int *arr) {
I have made a very simple Pie Graph generator using Javascript & SVG graphics.
I have the following Entity Framework model: It's a very simple model and was
I am trying to log in eclipse in a very simple test app.I have
I have a very simple Sinatra app which only does log out the params
My question is very simple: In an averagely complex web request, usually we have
I'm parsing some big log files and have some very simple string matches for
I have a very simple bit of code (relies on jQuery): var dom_builder =

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.