Hello dear list. I'm a self-learned java programming opera singer and I
would really like some input on the following problem.
In my attempt to build a satisfactory guestbook system I encountered the
following problem: I want to be able to administrate not only guestbook
style and behaviour but also single entries. Therefore I made two different
servlets, Guestbook and Guestbookadmin. But how do I avoid getting two
different instances of the current state? This is what I've done:
GBadmin is not importing state from the GB but getting a hold through an
interface like this:
private void getGuestbookConnection() throws ServletException, Exception{
ServletContext con = getServletConfig().getServletContext();
AdminInterface ai = (AdminInterface)con.getServlet("Guestbook");
// and so on...
}
The GB is the implementing AdminInterface and using its two methods:
public void adminOn() {
// change boolean isUnderAdmin to true, which is tested in the first
line
// of doPost() and turns user away to a "sorry, being administrated
// at the moment" - message, to ensure that the DB isn't changed
while someone
// is logged in on the GBadmin servlet
}
public void adminOff() throws Exception {
// flush the DB and read it again from file to get changes, set
isUnderAdmin to
// false again and send the Exceptions to the GBadmin servlet so the
can be
// dealt with on the spot
}
Now, my question is simple. Is there any reason this shouldn't work?
Thanks
- Lars J. Nilsson
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html