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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:57:50+00:00 2026-06-10T03:57:50+00:00

I have a register.jsp file. It reads the variable from a form submitted as

  • 0

I have a register.jsp file. It reads the variable from a form submitted as follows:

    <%
        if(request.getParameter("username") != null && request.getParameter("password") != null){
            String username = request.getParameter("username");
            String password = request.getParameter("password");
         }
     %> 

I have a java bean as follows.

public class RegistrationBean {


// Constructor
public RegistrationBean(){}  


public boolean login(String username, String password){
    boolean result = false;
    System.out.println("username");
    if(username.equals("username") && password.equals("admin")){
        result = true;
    }
    return result;
}


}

Now I am trying to call this login function in my jsp file as follows. I added the useBean at the top of my jsp file as well.

    <jsp:useBean id="register" class="registration.RegistrationBean" scope="session" />

    <%
        if(request.getParameter("username") != null && request.getParameter("password") != null){
            String username = request.getParameter("username");
            String password = request.getParameter("password");
            if(register.login(username, password)){
              // do something
            }
     %> 

But I realised that The value of username and password isn’t being passed to the bean. But when I print the value in .jsp file it had the appropriate value. Is there any reason why the value isn’t being passed to the function in the login() function. At the momen its false no matter what I do.

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-10T03:57:52+00:00Added an answer on June 10, 2026 at 3:57 am

    That should actually work.
    However, this is an alternate way of getting it to work:

    <jsp:useBean id="register" class="registration.RegistrationBean" scope="session">
    <jsp:setProperty name="register" property="username" value="<%=request.getParameter("username")%>"/>
    <jsp:setProperty name="register" property="password" value="<%=request.getParameter("password")%>"/>
    <jsp:useBean />
    

    Add setters and getters for username and password in your RegistrationBean class. username and password will be class variables. Make login function as non-parameterized i.e. call it as register.login().

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

Sidebar

Related Questions

I currently have two files, register.html and register.jsp. The HTML file asks the user
I have a register form in which i want when the user selects an
I have a Register and login page both using unobtrusive ajax. The Username property
I Have a register Form and I want to validate phone number in C#,
I have a web application (Java, Websphere, JSP) which allows co-workers to register visitors
I have a register form called server with fields Name, IP, Password. The form
I have a register.php file which creates new users for my site . But
I have the following JSP File and Servlet file <html> <head> <meta http-equiv=Content-Type content=text/html;
<form-bean name=RegisterForm type=com.mysite.form.RegisterForm /> <action path=/register type=com.mysite.action.RegisterAction name=RegisterForm input=/register.jsp validate=true> <forward name=success path=/welcome.jsp />
I have a register form, and I use a script to transform a location

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.