• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web-State Pattern

 
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been asked to look into the Web-State Pattern for some JSP / servlet work I'm about to start ... is this the same as the MVC pattern?
from what I understand both make use of JSPs (view) JavaBeans & Servlets (model & controller).
Has anyone done any development using this pattern? How does it essentially work?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may be related to the "State" pattern in GoF (always worth a re-read for any patter question). In the State pattern, the state of a process is represented by an instance of a class which implements an interface (or extends a particular base class). To change state, simply replace the state object with another object. The code using the state object neither knows or cares which state it is in.
For a web-specific use you might have a single JSP in which a named bean represents the state. Either in the JSP or in one or more associated servlets, you could make sure that the correct bean is in the session ready for the JSP each tim eit is called.
Does this make sense?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MVC-State Pattern is actually is the combination of MVC and State patterns. Main idea is based on a servlet that acts like a controller to get the requests from the web clients and delegate it to the model. So far it is pure MVC. The effect of State pattern comes when your model have different states and all these states are represented with different JSP. So the Context in the State pattern of GOF corresponds to the servlet itself. It sends the requests to State interface and depending upon the state which your state-dependent object is the servlet redirect the response to a different JSP, which is specificaly designed for that state. In this scenario, of course your servlet should know about which state is active.
Akin Kaldiroglu
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I finally got some documentation on this from someone here ... essentially it's a combination of state and MVC patterns.
The JSP being the view, Javabeans handle the model and we have controller Servlets there is also a state class which handles the state so the controller Servlet doesn't need to know the state .. it receives an HTTP request and invokes processRequest() on the instance of the State calss in the Session profile.
i think that's it ... the document is quite confusing I'll need to read through it again!
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Angela,
Can I you email the doc to me or give me the link where I can read it.
Thanks
Alok
(apota@dmotorworks.com)
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid it contains a lot of stuff confidential to the company. If I get time one day I might make a version of my own!
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic