Solved

jsp:setproperty not working

Posted on 2006-07-07
5
644 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
servlet concurrency 13 133
listing all functions in JavaScript 19 254
web application structure 18 136
servlet example 17 73
By reading this blog, MSPs will gain insight into how to improve communications with their clients as well as establish a more profitable business.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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