Solved

jsp:setproperty not working

Posted on 2006-07-07
5
639 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to write service layer in Spring ? 4 273
java beans and EJBs 5 182
spring example errors 33 201
instanceof  operator in java 26 73
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now