Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When does jsp:setProperty get called?  RSS feed

 
Roger Graham
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and why does this not work:

------------------------------------------------------
<%@ page import="questiondb.ResponderBean" %>

<jsp:useBean id="responderBean" class="questiondb.ResponderBean" scope="session">
<jsp:setProperty name="responderBean" property="*"/>
</jsp:useBean>


<html>
<head>
<title>Quick Test!</title>
</head>
<body>
<form action="PersistenceServlet" method="POST">
Name: <input type="name" size="30"><br>
Email: <input type="email" size="30"><br>
<br><Br><input type="submit" value="Post it!">
</form>
</body>
</html>
---------------------------------

I bind it to the session, but when I hit my servlet, the beans entries are null (not the bean itself however). Why are name and email not populated?

When does the setProperty thing actually do its stuff?


Thanks,
Rog
 
Roger Graham
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
errata: above - first mistake is:

<input type="text" >>>name<<<="name">
<input type="text" >>>name<<<="email">

Anyway, I tried that, and still get nulls for the values.. So the question still stands if someone can help me.

Thanks!
 
Roger Graham
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless I am mistaken, I think the idea is to do a HTTP POST to a JSP with these elements, then we can do the setProperty thing in the JSP we've sent the data to.... is this as dynamic as it gets? It seems annoying having a second 'receiver' JSP... can't we put everything in the same JSP?

Rog
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roger Graham:

<jsp:useBean id="responderBean" class="questiondb.ResponderBean" scope="session">
<jsp:setProperty name="responderBean" property="*"/>
</jsp:useBean>


When you put a setProperty tag in the body of the use bean tag, it will only get called the first time the page is called. Usefull for initializing.

Take it out of the body and it will get excecuted every time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!