File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem in setting value from one java file to another file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in setting value from one java file to another file" Watch "Problem in setting value from one java file to another file" New topic
Author

Problem in setting value from one java file to another file

Prasad Chelur
Greenhorn

Joined: Feb 12, 2002
Posts: 10
I am setting a string variable value from servlet file into java file.But the value is not retaining after the loop.
this is the sample code i have written for this
public class SetValue{
private String sStatus;
setValue{}
public void setStatus(String sStatus){
this.sStatus=sStatus;
}
}
this value i have setting from a servlet file.
public SettingServlet extends HttpServlet{
//my code
String sStaus="Value";
oBjofSetvalue.setStatus(sStatus);
}
in this my problem is after setting the value i am getting the string value null only.
it is setting the value i have tested, but when i access the value after that method has been set i am getting that value is null only.
i am not able to declare this variable as static here, bcz the design is like that.
plz give me soln,


prasadcts
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well there is a typo in sStaus.
I can't tell what oBjofSetvalue is.
I guess it is declared somewhere.
and Prasad,
Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
[ May 22, 2003: Message edited by: Cindy Glass ]
[ May 22, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
What is the scope for oBjofSetvalue? In order for it to persist across calls to the Servlet it should be either a Session object or a Context object depending on whether or not it should be global. If it is an instance variable in the Servlet, that is usually not a good idea because of threading issues and you can't be sure when the Web container will create a new instance and discard another.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Well there is a typo in sStaus.
Wow, you want to scan my code for typos Cindy? For 142, you sure do have a good set of eyes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in setting value from one java file to another file