Hello Emile,

The mmbase taglib stores the cloud in the session with the default name
"cloud_mmbase". If you want the same cloud then you could extend
org.mmbase.servlet.BridgeServlet. It has some methods which are usefull. Or
you could use the following code in your servlets.

   public static Cloud getCloud(HttpServletRequest request) {
        String sessionname = request.getParameter("session");
      if (sessionname == null || "".equals(sessionname)) {
         sessionname = "cloud_mmbase";
      }
      
        Cloud cloud = null;
      HttpSession session = request.getSession();
      cloud = (Cloud) session.getAttribute(sessionname);
      if (cloud != null) {
         log.debug("cloud for user " + cloud.getUser().getIdentifier());
      }
      else {
         CloudContext cc = LocalContext.getCloudContext();
         String cloudname = cc.getCloudNames().getString(0);

           String username = request.getParameter("username");
         String password = request.getParameter("password");
         if (username != null && password != null) {
            Map loginInfo = new HashMap();
            loginInfo.put("username", username);
            loginInfo.put("password", );
            cloud = cc.getCloud(cloudname, "name/password", loginInfo);
            session.setAttribute(sessionname, cloud);
         }
         else {
            // anonymous
            cloud = cc.getCloud(cloudname);
         }
      }
      return cloud;
   }

Nico

> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] Namens Emile
> Verzonden: donderdag 14 oktober 2004 18:33
> Aan: [EMAIL PROTECTED]
> Onderwerp: servlets
> 
> 
> Hi All
> 
> I'm struggling a bit with the cloud context and session 
> information when it comes to servlets.  If I simply want to 
> create a servlet which is called from code - jsp or other 
> servlets, what are the calling parameter pre-requisites if I 
> want to maintain cloud context?  In other words, what do I 
> need to put on the url by way of parameters and values for 
> the servlet to use current cloud and session context - I'll 
> copy andpaste code from the attachment servlet to interpret 
> these parameters.
> 
> Thanks
> 
> Regards
> Emile


Reply via email to