so please tell me how can the communication from my servlet class to the java class can happen ??
Okay so in your servlet you are doing this
And in your java class you are doing this
And you are expecting the value sld or sdo to be returned?? You just created a new object in your java class, how will the value magically transfer from your servlet to the normal class?? Can you show us the code where you are calling the normal java file in your servlet. You'll need to pass the FlagBean instance that you create in your servlet to the normal java class for the value to be able to reach the normal java class...
Ravi Kiran V wrote:.... don't create new class of FlagBean inside the java class but just call the getter Method it (Am i right to understand this properly ?)
Inside my Java class
FlagBean fb = new FlagBean() but just fb.getMethod()
You should call the getter of the object you have set the values in, perhaps passing that reference to your java class.
Lot of confusion over this one - so let me try taking up one point at a time,
Ravi Kiran V wrote:Hi ,
I am having a jsp page for submitting values .
--Sam - Right this works
All these values are recievied by a servlet .
--Sam - I think we are good up to this point too
This servlet in turn calls a normal java file
(This is the flow of our application)
--Sam - This is where the problem is - so lets clear up a few things.
There is no such thing as calling a Java File - unless you are using Runtime class to execute the file or something.
What you can do though is create an Object of the plain Java class and call a method or call static method of this plain java class and pass your bean as a parameter to the method!
It will be interesting to know what you are doing currently - I would suggest that you post your entire Servlet class if you are looking for more help!!
Ravi Kiran V wrote:seems interesting sam . ( I did not test for simultaneous requests actually )
But can you please tell me what will be the problem actually .
When you use static properties - you are just working with one copy of the variables. So if one request sets the value to 1 & another sets it to 2 the first value will get over written. Remember the container is going to span different threads to handle each incoming request - so you might end up with cases where you were expecting some value and ended up with another - and these kind of bugs might not even show up when you test the application under low load!
Why don't you do things in this way.
lets take an example :
suppose you have 1 text field named "myText" in jsp. you submitted form to your servlet in which you have called a java class.
Now myText comes in your servlet inside request object. you do 1 thing. pass this complete "request object" inside your java class constructor and assign it to instance variable and then use it in your methods.
why don't you pass the bean object (fb in your case)created in your servlet to your java class through constructor or method parameter of your java class and get the value from bean object.
Joined: Oct 06, 2008
samir singha wrote:why don't you pass the bean object (fb in your case)created in your servlet to your java class through constructor or method parameter of your java class and get the value from bean object.
Both are the same things. either direct fetch values from request or do one more step in which first populate bean then use in another class. Do any way you think is good
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: servlet setting some value need to retrive that value in a normal java file