• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using jsp:useBean

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to put some properties from a JavaBean (user) into the session scope after the user logs in. This is done via authentication.

I am sure that my JavaBean is written properly and that all the properties I want to put in the scope are there. The problem I have is that for some rezone when I try to use the bean method getName through jsp file I always get a null value. I already check the getName method by using system.out and it's working fine.

My user bean :

public class User{
private String name,userName,password;

public void setName(String p_name){
this.name = p_name;
}
public void setUserName(String p_userName){
this.userName = p_userName;
}
public void setPassword(String p_password){
this.password = p_password;
}
public String getName(){
return name;
}
public String getUserName(){
return userName;
}


My Link.jsp

<%@ page contentType="text/html; charset=windows-1255" %>
<%@ page language="java" import="obj.User"%>
<jsp:useBean id="user" scope="session" class="obj.User">
<jsp:setProperty name="user" property="*"/>
<%=user.getName()%>
</jsp:useBean>

Is there someone that have any idea what is the problem???

Thanks´┐Ż.chen
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chen I believe that there is a form through which you are getting some values... if it is the case ..pls. cross check that the form field name matches with that of the bean properties.. like if you have an input text box for getting username it should be like this



here name property userName is in accordance with the bean property and so when you call

Will work fine..
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1. JSP field name should match with the JavaBeans method name (as per java standard, the first letter must be in smaller case).

2. The javabean class should implement serializable interface.

Regards,
M.S.Raman
 
Chen Yanush
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

Tank's for the fest response but it's still don't work.
1)All the field name in LogOn.jsp matches with the javaBean fields (User) properties.
2)I implement Serializable in the bean.
3)All the first letter in my javaBean are in smaller case.
4)This is my LogIn.jsp (from there I get the data) file :

<html>
<head>
<title>LogIn</title>
</head>
<body>
<center>
<h1>Please Enter Your Personal Details</h1>
<form action="conservlet">
<table border=10 bordercolorlight="#00ff00" bordercolordark="#189234">
<tr>
<td>Name</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="userName"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"/></td>
</tr>
</table>
<br></br><br></br>
<input type="submit" name="Submit" value="Submit"></input>
<br><br>
</form>
</center>
</body>
</html>

Still looking for an answer,
By chen
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you get the userName??
 
Chen Yanush
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No !
 
Bindesh Vij
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Chen,
What is apparent to me is that the form that you have, does the action attribute specify the jsp page that you want to connect to. It seems like you have connected it to a servlet

 
Chen Yanush
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

First I would like to thank you for your rapid reply but I already located the problem.

I also have another question:
once I run my project and try to see my login.jsp page from another computer, by entering http://ip ort/myweb/login.jsp I can't see the page.

Do you know why? I understood that there should be no reason I can't see the page as the server is running on my computer.

Anyway, any help is deeply appreciated.

Thank you very much.

Regards,

Chen
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic