File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsps

 
haritha joshi
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1467
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haritha,
If possible post ur code of the jsp file.
Afroz
 
haritha joshi
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic