Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JSP problem

Options
  • 08-05-2006 1:41am
    #1
    Registered Users Posts: 6,420 ✭✭✭


    right, been having this problem for some time and its wrecking my head.

    Basically, I have a login form in a JSP. This uses a Bean (LoginDetails) to obtain the login details from another class(LoginHelper).
    Both these are contain in a package called login.
    They compile with no errors. However, tomcat is giving out the common error of:

    The value for the useBean class attribute app.login.loginDetails is invalid.

    The code is as follows

    Login_form.jsp
    <%@page contentType="text/html"%>
    <%@ page import="login.LoginDetails" %>
    <html>
    <head><title>Login Form</title></head>
    <body>
    
    <jsp:useBean id="loginDetails" class="app.login.loginDetails" scope="request" />
    <jsp:setProperty name="LoginDetails" property="*"/>
    
    <Form action="login.jsp" method="post">
    <table border='0'>
    <TR>
        <TD>
            Enter User ID:
        </TD>
        <TD>
            <input type='Text' name ='userID' value='<%=loginDetails.getUsername()%>'>
        </TD>
    <TR>
        <TD>
            Enter Password:
        </TD>
        <TD>
            <input type='Password' name ='password' value='<%=loginDetails.getPassword()%>'>
        </TD>
    </TR>
    <TR>
        <TD>
            <input type ='submit' value='Login'>
        </TD>
    </TR>
    </body>
    </html>
    

    LoginDetails.java
    package login;
    
    public class LoginDetails
    {
    	public LoginDetails()
    	{
    	}
    
    	String username;
    	String password;
    
    	public void setUsername(String username)
    	{
    		this.username = username;
    	}
    
    	public String getUsername()
    	{
    		return username;
    	}
    
    	public void setPassword(String password)
    	{
    		this.password = password;
    	}
    
    	public String getPassword()
    	{
    		return password;
    	}
    
    };
    

    LoginHelper.java
    package login;
    
    public class LoginHelper
    {
    	public boolean checkLogin(LoginDetails loginDetails)
    	{
    		if (("doodee".equals(loginDetails.getUsername())) && ("doodee".equals(loginDetails.getPassword())))
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}
    };
    

    The .java files and classes are located in the following directory address: app/login/

    I have also tried placing them in the WEB-INF/classes folder but with no luck.

    Any help is appreciated cause at this point I havent many hairs left to pull out.


Comments

  • Registered Users Posts: 1,996 ✭✭✭lynchie


    Your classes are defined in a package "login" whereas in the useBean you declare them as "app.login".


  • Registered Users Posts: 6,420 ✭✭✭Doodee


    if i change the package to app.login; and then try and compile I get the following

    LoginHelper.java
    login/LoginHelper.java:5: cannot resolve symbol
    symbol : class LoginDetails
    location: class app.login.LoginHelper
    public boolean checkLogin(LoginDetails loginDetails)
    ^
    1 error


  • Registered Users Posts: 6,420 ✭✭✭Doodee


    have changed the loginhelper code as I did not have a constructor.
    package app.login;
    
    public class LoginHelper {
    
    	public LoginHelper() {
    	}
    
    	public boolean checkLogin(LoginDetails loginDetails) {
    
    		if ( ("doodee".equals(loginDetails.getUsername())) && ("doodee".equals(loginDetails.getPassword())) )
    		{
    			return true;
    		}
    		else{
    			return false;
    		}
    	}
    }
    


  • Registered Users Posts: 1,996 ✭✭✭lynchie


    Doodee wrote:
    if i change the package to app.login; and then try and compile I get the following

    LoginHelper.java
    login/LoginHelper.java:5: cannot resolve symbol
    symbol : class LoginDetails
    location: class app.login.LoginHelper
    public boolean checkLogin(LoginDetails loginDetails)
    ^
    1 error

    And your java file is in the correct package structure too? i.e. app\login\LoginHelper.java and app\login\LoginDetails.java
    Also, have you changed LoginDetails package to app.login too?


  • Registered Users Posts: 2,932 ✭✭✭Sniipe


    so in his main folder he should have LoginForm.jsp and a folder called WEB-INF

    In the WEB-INF folder he has classes folder
    in the classes folder he has app folder
    in the app folder he has login folder
    in the login folder he has the class files

    would that be right?
    I don't know too much about JSP so I'm kind of interested in knowing how to do this.

    I've put his code onto my machine. And have the -> packages app.login; in the 2 java files.

    I still get the same error as Doodee:
    org.apache.jasper.JasperException: /LoginForm.jsp(5,0) The value for the useBean class attribute app.login.loginDetails is invalid.
    
    in LoginForm.jsp on line 5 I have:
    <jsp:useBean id="loginDetails" class="app.login.loginDetails" scope="request" />
    
    I don't see the problem.
    But I changed the word class to type and got this:
    [B]HTTP Status 500 - [/B]
    
    [B]type[/B] Exception report
    [B]message[/B] 
    [B]description[/B] [U]The server encountered an internal error () that prevented it from fulfilling this request.[/U]
    [B]exception[/B] 
    org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /LoginForm.jspGenerated servlet error:app.login.loginDetails cannot be resolved or is not a typeAn error occurred at line: 5 in the jsp file: /LoginForm.jspGenerated servlet error:app.login.loginDetails cannot be resolved or is not a type
    
    Is that progress in the problem or is that just making it worse?


  • Advertisement
  • Registered Users Posts: 2,932 ✭✭✭Sniipe


    try this: I got the page to appear
    [CODE<jsp:useBean id="loginDetails" class="app.login.LoginDetails" scope="request" />
    [/code]
    The L is capital


Advertisement