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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:03:08+00:00 2026-06-13T07:03:08+00:00

I have a problem regarding my simple application I have 2 separate .JSP file

  • 0

I have a problem regarding my simple application I have 2 separate .JSP file let say register and login.jsp both have submit action and both this jsp share the same servlet let say usercontrol.servlet how can I call the action once the login button is clicked the same also with register.jsp if they sharecommon servlet?

here is my servlet code:

if(request.getParameter("register").equals("Register")){
            if(request.getParameter("first") == "" || request.getParameter("middle") == "" || request.getParameter("last") == "" || 
                    request.getParameter("loginid") == "" || request.getParameter("pass") == "" || request.getParameter("pass2")== ""){
                JOptionPane.showMessageDialog(null, "Cannot leave null value from one of the textfields");
                response.sendRedirect("AdminPage/Register.jsp");

            }
            //else if(request.getParameter("pass") != request.getParameter("pass2")){
                //JOptionPane.showMessageDialog(null, "Password Mismatch, Check you password and retype it correctly");
                //response.sendRedirect("AdminPage/Register.jsp");
            //}
            else{
                RegisterUser(request, response);
            }
    }

    else if(request.getParameter("login").equals("Login")){
        if(request.getParameter("username") == ""){
            JOptionPane.showMessageDialog(null, "Username is required");
            response.sendRedirect("AdminPage/Login.jsp");
        }
        else if(request.getParameter("password") == ""){
            JOptionPane.showMessageDialog(null, "Password is required");
            response.sendRedirect("AdminPage/Login.jsp");
        }
        else if(request.getParameter("username") == "" || request.getParameter("password") == ""){
            JOptionPane.showMessageDialog(null, "Password/Username is required");
            response.sendRedirect("AdminPage/Login.jsp");
        }
        else{
            LoginUser(response, request);
        }   
    }

I’m integrating my application with hibernate.

this are my jsp submit buttons I did not include the whole forms I just include the submit button.

Login.jsp

<input type="submit" name="login" value="Login" />

Register.jsp

<input type="submit" name="register" value="Register"/>

My question is everytime I run the application it always does all the action in the if..else statement is there any other ways to fix this?

  • 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-13T07:03:09+00:00Added an answer on June 13, 2026 at 7:03 am

    In your jsp you should have submit button as

    for login.jsp

    <input type="submit" name="login" value="Login"/>
    

    for register.jsp

    <input type="submit" name="register" value="Register"/>
    

    Now in servlet you can check like

    if(request.getParameter("login") != null) {
      // request is comming from login jsp
      // do validation, perform actual transaction 
    } else if(request.getParameter("register") != null) {
      // request is comming from register jsp
      // do validation, perform actual transaction 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple problem regarding a loop in a Rails controller. Here's the
I have a problem regarding Android App. I have created an application that download
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
I have a problem regarding the datediff MYSQL function, I can use it and
I have a problem regarding the ksoap2. My problem is that the project used
Description: I have a problem regarding DataGridView . I need to show a Client_Name
I have the following code, and i have a problem regarding changing the ringtone
Good day everyone! I have a problem regarding my date. It needs to be
I am new to jQueryMobile. I have one problem regarding fixed headers. I have
I have a cross-language problem regarding md5 :). I have this code in Java:

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.