Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't read request attribute 1

Status
Not open for further replies.

tvrtko

Programmer
Nov 26, 2003
53
HR
My JSP page looks like this:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="mypackage.MyClass"%>
<html>
<head><title>JSP Page</title></head>
<body>

<a href='/IGZ/imovina/prostora'>Prostori</a>
<a href='/IGZ/imovina/zemljista'>Zemljista</a>

<jsp:useBean id="mybean" scope="request" class="mypackage.MyClass" />

<jsp:setProperty name="mybean" property="prop" value="somevalue" />

</body>
</html>

When I try to get that bean from request in servlet:

MyClass mybean = (MyClass)request.getAttribute("mybean");

the result is null.

What I have done wrong?
 
probably because you've scoped your bean as "request", so it only exists while that current request is executing. so after that page renders, the request is over, hence the bean no longer exists.

try using "session" scope to persist across requests


-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top