aspose file tools*
The moose likes Servlets and the fly likes Jsps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Jsps" Watch "Jsps" New topic
Author

Jsps

haritha joshi
Greenhorn

Joined: Oct 31, 2000
Posts: 5
Hello All
I am learning Jsp. I did a program where in login and passwrd are entered thru a html page when we submit the page it calls the a login.jsp program this prg uses a login bean and uses a set property to set the values to login and password in the bean. I am using getProperty to get the values of login and passwrd. But it is not displaying nothing. can any help me by giving any hint or any program which will use bean and set the values using the setProprty and get the values using getProperty.I did startserver.

Thxs for Help.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Haritha,
Did you take care of the names of the fields in the Form? The names of the Form and the member names of the Bean must match. It is also case sensitive. Then you can set the Bean's members to grab the values of the SAME form fields like this.Also note that the minimum needed requirements for a bean is all set*** and get*** methods where *** denotes the member names. You need to take care of the methods also. I just copied a sample code from another post. Please check it up.
regds
maha anna
Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
Haritha,
If possible post ur code of the jsp file.
Afroz

Afroz
haritha joshi
Greenhorn

Joined: Oct 31, 2000
Posts: 5
Hello
Here is the code . I will be thankful if any one helps
login.html
<!-- Login and password program -->
<html>
<title> Login and password </title>
<body>
<FORM TYPE=POST ACTION="\examples\jsp\myjsp\Login.jsp">
LOGIN : <input type= text name="login" size="16">
PASSWORD : <input type="password" name = "pwd" size = "16">
<input type="Submit" value ="SUBMIT" >
</form>
</body>
</html>
Login.jsp:

<!-- JSP PAGE FOR LOGIN AND PASSWORD -->
<html>

<body bgcolor="white">
<font size=5 color="red">
<jsp:useBean id="lop" scope="session" class="Login.LoginTest"/ >

<jsp:setProperty name="lop" property="login" param="login" />
<jsp:setProperty name="lop" property="pwd" param="pwd" />
<hr>
The Login and password you entered (got using request) are: <br>
<% String l = request.getParameter("login");
String p = request.getParameter("pwd");
out.println(l + " entered login" ); %>
<br>
<%
out.println(p + " entered password");
%>
<br>
<hr>
The login and passwrd using getproperty are: <br>
<h4> Login: <jsp:getProperty name="lop" property="login" /></h4>

<h4> Password: <jsp:getProperty name="lop" property="pwd" /></h4>
<br>
<hr>
The values of login and password (got using beans methods getlogin and getpassword) are <br>
<br>
<%= lop.getLogin();
%>
<%= lop.getPassword();
%>
</font>
</body>
</html>

Bean for login and password ( LoginTest.java)
package Login;
public class LoginTest {
String login = null;
String pwd =null;
public String getLogin() {
return login;
}
public String getPassword() {
return pwd;
}
public void setLogin(String s) {
this.login = s;
}
public void setPassword(String k) {
this.pwd = k;
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jsps