The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

shekhar.otari (7) [Avatar] Offline
#1
Is there anything similar to session management in GWT? If no, how the application running on the server (implemented in Servlet) will authenticate the user request that comes from GWT client.
dialloma (72) [Avatar] Offline
#2
Re: Session management in GWT
Hi,

You can send the XML or JSON file from your GWT client application to your server (any type of server implementation safe GWT - RPC). In the GWT, there are a APIs that help you to create and parsing the XML and JSON files. So in a server side you can use the sessions to authenticate your application users. Hope that this help you.
Thanks
dialloma
shekhar.otari (7) [Avatar] Offline
#3
Re: Session management in GWT
Hi,

Thanks for reply. I am unaware about how to send the request in the form of XML. It would be helpful if you can put some light on it.

The scenario is: Our project is in design phase. The client side will be written completely in GWT. The server side will have Servlets, Web services, EJB, databases, etc. The client will send the request to the Servlet completely in the form of XML. The Servlet will fetch and parse the request XML using XMLInputFactory and XMLStreamReader classes available in JDK. Then depending upon the data contained in XML, the appropriate Web service will be called which in turn give the call to EJB and so on. The response will also go in the form of XML data only to the client in the reverse way. We are not going to use GWT-RPC here to make the server and client completely independent of each other.

The question here is how the XML request (request in the form of XML text only) will be posted to Servlet over the network.
dialloma (72) [Avatar] Offline
#4
Re: Session management in GWT
It's not very difficult!
As I said in my last message, In GWT there are the APIs that can help developper to manipulate the JSON and XML files. You can see in GWT documentation here http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/index.html the XMLParser and JSONParser classes. They content all you need to create and parsing XML and JSON files. So in your GWT client application, you can extract datas the TexBox, TextArea or anothers compoments and create your XML or JSON file as a String.
For sending it to the server, you use the HTTP protocol. In GWT there mainly two classes to help you to do that: RequestBuilder and HTTPRequest. There contents the GET and POST Http verbs. You can see details and examples in the GWT documentation. You can also use native JavaScript code (with XMLHttpRequest) in the GWT code to send your datas to the server. In the GWT book, read the JSNI chapter.

Thanks
dialloma
shekhar.otari (7) [Avatar] Offline
#5
Re: Session management in GWT
Thanks again for your immediate reply. I'll definitely try this option. Just for information, we are not going to use JSON in our project. The communication for our project is solely based upon XML data.
adam.tacy (269) [Avatar] Offline
#6
Re: Session management in GWT
Hi,

Don't forget that all GWT is is standard JavaScript and HTML, so any session management you would normally use with those technologies is still be valid.

There's quite a few posts on the GWT forum which might be of use to you:

http://groups.google.com/group/Google-Web-Toolkit/search?group=Google-Web-Toolkit&q=session+management&qt_g=Search+this+group

Hope that helps!

//Adam
dialloma (72) [Avatar] Offline
#7
Re: Session management in GWT
It doesn't matter. If you have a JSON paser API for your server side, I recommand you that to use it, because parsing a JSOn document is very faster than parsing a XML document and in GWT the code for parsing JSON is verry simple than the XML code. But if you prefer XML or if you have a constraint it's not a problem.

dialloma