• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Life Cycle

 
Jason Mil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 11165
    14
    Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Jason Mil
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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".
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic