It's not a secret anymore!*
The moose likes Servlets and the fly likes Any Solution to Break/Overlook  the Session Variables ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Any Solution to Break/Overlook  the Session Variables ?" Watch "Any Solution to Break/Overlook  the Session Variables ?" New topic
Author

Any Solution to Break/Overlook the Session Variables ?

Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
Hi Ranchers,

Is there any way to break the sessions in a web application ?

i.e., Can i display or run Jsp's or Servlets which are in between the web application directly from the Browser by giving its URL alone , even if they (Jsps/servlets) are attached with session-scope.


My problem is here from this situation :

I will give a brief on my application's process flow.

OnlineStore ---> Product Listing ---> Shopping Cart -->Payment Process/Order Completion.

Here a User(has to register if he is new)
Logins the Store ,
Moves his product to the Shopping cart ,
Places the Order.

Can i display or run the Shopping Cart (for ex: shoppingcart.jsp) page by giving its URL from the Browser.

Presently , since the session variables are attached , if i do this i am getting Page session Expired Message .

I am trying this since i have to integrate/call/run/display an intermediate page into another web application.

Expecting a solution or Some alternate solution or guidance in this Struck.

Thanks.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53

OnlineStore ---> Product Listing ---> Shopping Cart -->Payment Process/Order Completion.

you've already defined a work flow your self, and for sure when you want to reach the shoppingcart.jsp it will give an exception because rendering this page has so many session-depended values I believe so.
And just by writing the URL to that page without preparing the session with the needed values, you'll keep on having the same errors, but I see that there's no use of reaching a state of the work flow directly, anyway that's why it was called work flow.


Qussay NAJJAR
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
Thanks Qussay.

Is there any other alternate for this situation ?

Can't we reinitialize the session dependant values in the above specified shoppingcart.jsp. Am i right on this query?

I am trying this since i am in a position to reuse an existing application in such a way that without coding/new coding.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
I didn't get you exactly, could you explain more or maybe show me the navigation you want to do..
abhishek jethwani
Greenhorn

Joined: Aug 11, 2006
Posts: 14
i think the problem is with session that you create and try to continue.

had you tried it with cookies, i think it will work.


or you can do one thing save the session id once its created for the user and check the login name and allocat same id to the login name.

i think it will work..

pleasee, correct me if i m wrong
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
I didn't get you exactly, could you explain more or maybe show me the navigation you want to do..


We are having an Online Shopping Application(Say WebApp-B) with this flow :

OnlineStore ---> Product Listing ---> Shopping Cart -->Payment Process/Order Completion

Presently i have to reuse this with another WebApp(Say WebApp-A).

--->Shopping Cart -->Payment Process/Order Completion

I need to reuse only this above segment of WebApp-B with another application WebApp-A.


WebApp-A ===> WebApp-B

Here I am selecting a data(Say a product name, product id etc) from WebApp-A and passing straight to Shopping Cart of WebApp-B , So that the selected product in WebApp-A will now sit in the Shopping cart of WebApp-B and then Order is Placed.

I hope this gives you a clear picture.
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
save the session id once its created for the user and check the login name and allocat same id to the login name



WebApp-A ===> WebApp-B

As per the above quote :
1. I have to use the session id from WebApp-B with WebApp-A.
2. So that WebApp-A and WebApp-B will have a unique session(same session as if a Single WebApp). So that i can attach WebApp-B with WebApp-A and then I can call/run the URL of WebApp-B in WebApp-A.

Is that your suggestion ?

Thanks.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Ok Jesu, now I got what you want..
you know the thing that first came to my mind is the next:

Now because Shopping Cart is used more than once, but different applications then you have
to take in consider the values coming from different sites and make them the same,
and to make it practical Shopping Cart should have the same code, but modify the work flow to:

OnlineStore ---> Product Listing ---> (Some Servlet) --> Shopping Cart -->Payment Process/Order Completion.

now this Servlet should conditions inside to decide what to transfer to Shopping Cart.



and to get to know which application the request is coming from you can use url parameters,
example:
- Product Listing will dispatch with URL="SomeServlet?webApp=A"
- A page from WebApp-B will dispatch with URL="SomeServlet?webApp=B"

Hope it helped, I believe this would work, I told you this is the first thing that I thought of..
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Originally posted by abhishek jethwani:

had you tried it with cookies, i think it will work.


I believe that won't work because simply the user might block cookies and then your application won't work.

Originally posted by abhishek jethwani:

or you can do one thing save the session id once its created for the user and check the login name and allocat same id to the login name.


Honestly haven't tried this before, but I believe it's not practical, I don't know..!!!
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
Thanks a lot.

I got the flow. Next i got to work with handling sessions between different applications.

I ll get back , if any.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
It seems to me you need to back off a bit and look at your problem with a fresh eye. There are plenty of ways to store information about a user or a shopping cart that don't involve putting everything in a session.

In my experience, a custom object that can be serialized to disk or other storage is very effective in holding user data for any length of time. Then your session problem is reduced to linking a user with the serialized object.

Bill
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
.. a custom object that can be serialized to disk or other storage is very effective in holding user data for any length of time. ..


You mean that the data can be stored in files or in database , so that they can be queried on later.

Can you Pl. put me more light on this - How to move on this approach ?

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jesu Mani:
... Can you Pl. put me more ...


Jesu Mani,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseRealWords

Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
'Pl' is not a word in the English language and this thread is difficult enough to read without adding non-words to the mix.

Again, welcome to JavaRanch and good luck with your question.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Can you Pl. put me more light on this - How to move on this approach ?


Sure:

1. Study the object serialization classes such as ObjectOutputStream and ObjectInputStream in the java.io package. Write a simple Serializable class and experiment with writing and re-reading instances. NOT in a servlet, servlets just add complications.

2. Expand your serializable class with your shopping cart variables - testing with synthetic data so you can have serialized objects representing user data at various stages of your data flow to make it easier to test.

3. Figure out a scheme for unique naming of the serialized object files so they can be associated with a particular user.

Let us know your progress

Bill
Jesu Mani
Ranch Hand

Joined: Oct 16, 2006
Posts: 34
1. Study the object serialization classes


Thanks for your Timely support.

I will hava a study on the object serialization classes , try out with some samples and will try to implement on my flow.

I will keep in touch with you parallely during my progress.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any Solution to Break/Overlook the Session Variables ?