Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in setting value from one java file to another file

 
Prasad Chelur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic