Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-15-2008, 07:34 PM
Member
 
Join Date: May 2008
Posts: 18
Rep Power: 0
impact is on a distinguished road
Default Bean class error
Can some one tell me why the value from the servlet class is not reaching the bean class?

Here is my servlet

Code:
try{
        StringBean bean = new StringBean();
        bean.setBean(value);
        request.setAttribute("result", bean);
        }catch(Exception e){
            e.printStackTrace();
        }
Here is my bean class (StringBean)

Code:
package pack01;

public class StringBean{
    private String answer="Hi";

    public void setBean(String value){
        answer = value;
    }
    
    public String getBean(){
        return(answer);
    }
}
When I run my program I only see Hi as the output. Some how the value is not reaching the StringBean class.

Many thanks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-15-2008, 08:28 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Have you tried debugging the code by using println()s?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-16-2008, 05:41 AM
Member
 
Join Date: May 2008
Posts: 18
Rep Power: 0
impact is on a distinguished road
Default
Yes, it works fine. Some how I am not able to transfer the value to StringBean as I am able to get Hi as the output.

Thanks for your help.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-16-2008, 02:00 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
Yes, it works fine.
??? Then there is no problem if it works. Is that right?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-16-2008, 03:08 PM
Member
 
Join Date: May 2008
Posts: 18
Rep Power: 0
impact is on a distinguished road
Default
I think I dint understand your question. What works fine is, when I try to print the value using the servlet it actually prints the value. When use StringBean class, that is from servlet send the value to the StringBean class and then try print the out put, all I get is "Hi", which is the default String variable value in StringBean class.

some how I am not able to transfer the calculated value from the Servlet to the StringBean class and then print it.

by the way, what did you mean by "Have you tried debugging the code by using println()s?"
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-16-2008, 03:46 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Put a println() statement in the set method to see is it's called and with what value.
Also use println() to see if the object you put/set in attributes is the same as the one being used with the get method.

Last edited by Norm; 08-16-2008 at 04:37 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error deploying Entity Bean RobertoWIN_MX Enterprise JavaBeans 1 05-23-2008 08:15 AM
How to write a java bean class object to XML file Java Tip java.io 0 04-06-2008 07:43 PM
How to use Inner bean definitions via nested bean elements JavaBean Java Tips 0 09-26-2007 08:36 PM
Error in class ai_2007 Advanced Java 1 07-09-2007 04:06 PM
Struts tag error with bean:write sandor Web Frameworks 1 04-07-2007 04:50 AM


All times are GMT +2. The time now is 09:49 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org