aspose file tools*
The moose likes GWT and the fly likes Servlet Life Cycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Servlet Life Cycle" Watch "Servlet Life Cycle" New topic
Author

Servlet Life Cycle

Jason Mil
Greenhorn

Joined: Aug 02, 2011
Posts: 2
Hello,

I'm new to web dev and especially to GWT. I would like to make some points clear in order to start my project on good basis:

  • When are the RemoteServiceServlet objects created, destroyed, and by who? One for each browser window? For example, for a typical login form, one only needs to store the current user's information in the members of the servlet and they will be kept until the browser is closed?


  • What are the best ways to split an application into servlets? What would be the relevant criterions for grouping requests in the same servlet?


  • If a XML file is parsed client-side in JAVA giving a static path aiming to my disk, the generated JavaScript code will not contain any evidence of this file being read, right? In other words, most of the client-side java code is preprocessing from the compiler point of view?


  • Thanks!
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10403
        
        8

    Welcome to the Ranch.

    For a more detailed explanation of the RPC mechanism, you can refer to http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html#DevGuideRemoteProcedureCalls

    If you are using pure RPC, you don't really need multiple servlets. Just one XXXImpl with different methods
    What would be the relevant criterions for grouping requests in the same servlet?

    I am not really sure I understand what you are trying to say here. The XXXImpl is effectively a servlet. You can very well have an application, which only one servlet (viz. XXXImpl) but with different methods to handle different data/functionality. e.g. your XXXImpl can have methods like registerUser(), loginUser(), updateUser() etc.

    If a XML file is parsed client-side in JAVA giving a static path aiming to my disk, the generated JavaScript code will not contain any evidence of this file being read, right? In other words, most of the client-side java code is preprocessing from the compiler point of view?

    GWT is compiled into JS. All you can do on the client side is choose a file and upload to the server.


    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
    Jason Mil
    Greenhorn

    Joined: Aug 02, 2011
    Posts: 2
    Thanks for your reply.

    From what I've read, a servlet object is created only once when the server is launched, not for every client session. Some tutorials are somewhat confusing: the user's information are stored in a pair of attributes (username, password) of the servlet, which means that all the users will actually share the same information. It does not make sense. Anyway, calling getThreadLocalRequest() is the best way to know which user the request is sent from?

    GWT is compiled into JS. All you can do on the client side is choose a file and upload to the server.


    For instance, in the client side I have the following java code:

    The generated javascript will look like this?

    It is what I meant by "preprocessing".
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Servlet Life Cycle