Re: [appengine-java] Setting some Cookies?

2010-05-17 Thread Ikai L (Google)
If you're trying to separate logic from view, it'll be better to use a
Servlet with JSP dispatch:

http://www.brics.dk/~amoeller/WWW/jsp/jspservlets.html

You set your variables you need in your JSP via the Request Content
(request.getAttribute(), request.setAttribute()). You can fetch these in the
JSP. It'll be easier for you to set and get cookies in the servlet than the
JSP - code in JSPs is generally regarded as bad style and should be avoided
when possible.

On Fri, May 14, 2010 at 12:55 AM, Mark  wrote:

> Hi,
>
> I'd like to add a cookie to a client request. I have a jsp page I'm
> serving from app engine. Is this correct?:
>
>  // index.jsp:
>  <%@ page import="com.me.myproject.server.Util" %>
>
>  Util.addCookie(response);
>
>
>
>  // Util.java
>  import javax.servlet.http.Cookie;
>  import javax.servlet.http.HttpServletResponse;
>
>  public class Util {
>
>  public static void addCookie(HttpServletResponse response) {
>  Cookie cookie1 = new Cookie("param1", 123);
>  Cookie cookie2 = new Cookie("param2", 456);
>  response.addCookie(cookie1);
>  response.addCookie(cookie2);
>  }
>  }
>
> mostly confused about 'response' just being globally available in my
> jsp (I think this is just how jsps works) and if it is in fact of type
> "HttpServletResponse"? I think then that it's ok to just pass it to my
> java file from the jsp page?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
Ikai Lan
Developer Relations, Google App Engine
Twitter: http://twitter.com/ikai
Delicious: http://delicious.com/ikailan


Google App Engine links:
Blog: http://googleappengine.blogspot.com
Twitter: http://twitter.com/app_engine
Reddit: http://www.reddit.com/r/appengine

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Setting some Cookies?

2010-05-13 Thread Mark
Hi,

I'd like to add a cookie to a client request. I have a jsp page I'm
serving from app engine. Is this correct?:

  // index.jsp:
  <%@ page import="com.me.myproject.server.Util" %>

  Util.addCookie(response);



  // Util.java
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletResponse;

  public class Util {

  public static void addCookie(HttpServletResponse response) {
  Cookie cookie1 = new Cookie("param1", 123);
  Cookie cookie2 = new Cookie("param2", 456);
  response.addCookie(cookie1);
  response.addCookie(cookie2);
  }
  }

mostly confused about 'response' just being globally available in my
jsp (I think this is just how jsps works) and if it is in fact of type
"HttpServletResponse"? I think then that it's ok to just pass it to my
java file from the jsp page?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.