Solved

jsp:setproperty not working

Posted on 2006-07-07
5
647 Views
Last Modified: 2010-07-27
having troubling getting the jsp:setProperty to work.  here is my jsp page and bean...can anyone tell me why this is not working?  If i explicitly set the value="something" then setProperty works, but I need to capture the html input...thanks in advance!

here's my jsp page called login.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page session="true" %>
   
        <jsp:useBean id="user" scope="session" class="org.stuff.domain.User">
                  <jsp:setProperty name="user" property="*"/>
       </jsp:useBean>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

username: <%= user.getUsername() %>

<br/>
<form action="login.jsp" method="post">

Login id:
<input type="text" name="username" size="10"/>
<br/>
Passwd:
<input type="password" name="password" size="10"/>
<br/>
 <input type="submit" name="submit"/>
</form>
</body>
</html>


And here is my bean:

package org.stuff.domain;

public class User implements java.io.Serializable {

      private String username;
      private String password;
      
      public User() {
      // TODO Auto-generated constructor stub
      }
      public String getPassword() {
            return password;
      }
      public void setPassword( String password ) {
            this.password = password;
      }
      public String getUsername() {
            return username;
      }
      public void setUsername( String username ) {
            this.username = username;
      }
0
Comment
Question by:GrnEggsAndHam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 8

Accepted Solution

by:
thomas908 earned 500 total points
ID: 17056787
put your
 <jsp:setProperty name="user" property="*"/>
outside your
<jsp:useBean .../>
0
 
LVL 8

Expert Comment

by:thomas908
ID: 17056789
<jsp:useBean id="user" scope="session" class="org.stuff.domain.User"></jsp:useBean>
 <jsp:setProperty name="user" property="*"/>
0
 
LVL 8

Expert Comment

by:thomas908
ID: 17056794
Body tags are only processed if <jsp:useBean> instantiates the Bean. If the Bean already exists and <jsp:useBean> locates it, the body tags have no effect.
Using

 <jsp:useBean id="user" scope="session" class="org.stuff.domain.User" />
 <jsp:setProperty name="user" property="*"/>

will set the property even if the bean already exists
0
 
LVL 8

Expert Comment

by:thomas908
ID: 17056805
0
 
LVL 2

Expert Comment

by:vikrant4u2
ID: 17056843
remove scope="session" and it will work

regards,
vikrant
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question