• 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

get JavaBean properties in any jsp not just consecutive

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic