Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get JavaBean properties in any jsp not just consecutive

 
uday batta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an index.jsp file, which displays login form. i have JavaBean class which has setter and getter methods.

i want to develop a servlet,that sets the JavaBean properties. so that i can get those properties in any jsp(not the consecutive one) using the following code.

<jsp:useBean id="user" class="com.PersistenceJavaBean" scope="session" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OUTPUT</title>
</head>
<body>

Username is: <%= user.getUsername() %>

Password is: <%= user.getPassword() %>

</body>
</html>


i should retrieve the login data, whatever jsp, i use the above code in.

how can we retrieve login data in any jsp, using the above code,once we set the JavaBean properties in a servlet

give me solution without using <setProperty> , <getProperty>, session.getAttribute() , request.getAttribute() in jsp.

and how the servlet will be??

its urgent

thanks
uday
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the information is set in the session, and JSP page displayed during that session will be able to access the data.

You should be using the EL and JSTL, not Java scriptlets in your JSP. As such, a bean in session scope can be accessed via: ${sessionScope.myBean} or just ${myBean} if its name is unique in all the scopes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic