I am using cookies for login ! Which would you prefer ? Session or cookies ?
On Thursday, 1 March 2012 12:10:38 UTC+5:30, Maverick wrote: > > Write a service on Server side which extends RemoteServiceServlet. > Create an object of type HttpSession as a member. > Write methods to serAttribute and getAttribute. > > > > > On client side. Inject the service and call setAttribute and > getAttribute methods wherever you want to add data to session or read > data from session. > > > > > Refer sample code below: > > > > > SessionService ( On server side) > > > > > import java.awt.List; > > > > > import javax.servlet.http.HttpSession; > > > > > > > > > import com.google.gwt.user.server.rpc.RemoteServiceServlet; > > > > > > > > > @SuppressWarnings("serial") > public class SessionImpl extends RemoteServiceServlet implements > ISession { > > > > > > public static HttpSession httpSession; > > > > > > > > > > > @Override > public String getStrAttribue(String attribute) { > httpSession = getThreadLocalRequest().getSession(true); > return (String) httpSession.getAttribute(attribute); > } > > > > > @Override > public void setAttribue(String attribute, String attValue) { > httpSession = getThreadLocalRequest().getSession(true); > httpSession.setAttribute(attribute, attValue); > > } > > > > > > > > > > } > > > > > > > > > > > > > To use session (on client side) > > > > > @Inject > public ISessionAsync session; > > > > > > session.setAttribue("User","Sujit",new AsyncCallback<Void>() { > > @Override > public void onSuccess(Void > result) { > //some event > } > > @Override > public void > onFailure(Throwable caught) { > // TODO Auto-generated > method stub > > } > }); > > > > > > > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/BqhRU2EkB-UJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.