Re: xsp session logicsheet

2003-02-05 Thread Cyril Vidal

Hi Roman,

thank you very much for your reponse.
I know that in theory, using actions is better than simply mixing pure Java
code in XSP pages. But it's true that I must go quite quickly, and just to
have an idea of how sessions work in Cocoon, I just would to have a first
try with the second solution. Of course, I have in project to have a deeper
understanding of what goes on under the hood with actions, but a little bit
latter. AFAIK, this concept is not really simple to figure out...

The solution you suggested to me works well, thanks:



http://apache.org/xsp";

xmlns:xsp-session="http://apache.org/xsp/session/2.0";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";

create-session="true">



java.util.Vector







Vector items = (Vector);

if (items == null) items = new Vector(10,5);

items.add();

session.setAttribute("cart.items",items);

The list of items is: 










But the result is of the following form:

  The list of items is: 1336364336433643323643
  and I would like better it would be of this form:
The list of items is:
.133636
433
643
3643
323643
So instead of the following code,
The list of items is: 

I' ve tried the following one:
The list of items is:

for (int i = 0; i < items.size(); i++) {
items.get(i)
}
 

I have the following error:
Line 226, column 59:  variable i not found in class
org.apache.cocoon.www.mount.essai.session3_xsp

Christian Haul has already taken pains (one more time) to explain me what
went wrong, but I'm afraid I've not all understood. I've casted the former
Object items onto Vector one, as suggested,
but it doesn't seem to be sufficient.

Have any idea?

Regards,
Cyril.



> Hi Cyril,
> you do not have to use actions if you do not want :-)
> As I said, when you use session namespace, there is always a variable
> session there in the generated java code. You can access this session
either
> directly in xsp page from within  tags, or you can write your
own
> taglib. This taglib can then implicitly use session variable, though it
will
> never be declared there. What I propose to you is a kind of dirty
> programming style, but as I understood you want a quick solution.
>
> Try something like this, you have to experiment and always look at the
> generated code:
>
> 
>  xmlns:xsp="http://apache.org/xsp";
> xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> xmlns:xsp-request="http://apache.org/xsp/request/2.0";
create-session="true">
>
> 
>   
> // beginning of the java code
>
> try {
>// Cart items are maintained in the session object.
> Vector items = (Vector)session.getAttribute("cart.items");
>  if (items == null) { items = new Vector(10,5);}
>
>String item = req.getParameter("item");
>items.add(item);
>
>session.setAttribute("cart.items",items);
>   
>
> The list of items is:  default="not set"/>
>
> 
>
> 
>
> Roman
>
>
> -Original Message-
> From: Cyril Vidal [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 05, 2003 1:53 PM
> To: [EMAIL PROTECTED]
> Subject: Re: xsp session logicsheet
>
>
>
> Hi Roman,
>
> Indeed I've done this:
> 
>
> 
> xmlns:xsp="http://apache.org/xsp";
>
> xmlns:xsp-session="http://apache.org/xsp/session/2.0";
>
> xmlns:xsp-request="http://apache.org/xsp/request/2.0";
>
> create-session="true">
>
> 
>
>  name="item"/>
>
> The list of items is:  default="not set"/>
>
> 
>
> Your session was created:  as="string"/>
>
> 
>
> 
>
> My problem is the following: I would like to add items to the attribute's
> session 'cart.items'.
> For the moment, the preceding code doesn't do this task.
> When I call http://localhost:8080/cocoo/mount/try/session.xsp?item=3
>
> I receive the following html result:
> The list of items is: 3
> Your session was created: Wed Feb 05 13:41:32 CET 2003
>
> when I then call http://localhost:8080/cocoo/mount/try/session.xsp?item=5
> The result is the following:
> The list of items is: 5
> Your session was created: Wed Feb 05 13:41:32 CET 2003
>
> and of course, I would like
> The list of items is: 3, 5
> Your session was created: Wed Feb 05 13:41:32 CET 2003
>
>
> What i would like to know : is it possible to achieve this task by using
> Session Logicsheet by itself, does this Logicsheet provides this
> functionnality?
> If not, the alternative is also to use actions, as suggested in this
thread
> before?
> Is a built-in action available f

Re: xsp session logicsheet

2003-02-05 Thread Christian Haul
On 05.Feb.2003 -- 04:53 PM, Cyril Vidal wrote:
> I think I'm on the point of being successful with my business.
> But I still have one question, considering the following  short code and
> especially the uncommented snippet: (serves to retrieve and display all the
> items of the current session)
> 
> 
> 
> 
>  
> xmlns:xsp="http://apache.org/xsp";
> 
> xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> 
> xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> 
> create-session="true">
> 
> 
> 
> java.util.Vector
> 
> 
> 
> 
> 
> 
> 
> Object items = ;
> 
> if (items == null) items = new Vector(10,5);
> 
> ((Vector) items).add();
> 
> session.setAttribute("cart.items",items);
> 
> 
> 
> /**Error here:  method get() and variable i are not known from
> Cocoon's servlet
> 
> 
> 
> for (int i=0; i items.get(i)
> 
> }
> 
> 
> 
> **/
> 
> 
> 
> 
> 
> 

Chris.
-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp session logicsheet

2003-02-05 Thread Cyril Vidal
I think I'm on the point of being successful with my business.
But I still have one question, considering the following  short code and
especially the uncommented snippet: (serves to retrieve and display all the
items of the current session)




http://apache.org/xsp";

xmlns:xsp-session="http://apache.org/xsp/session/2.0";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";

create-session="true">



java.util.Vector







Object items = ;

if (items == null) items = new Vector(10,5);

((Vector) items).add();

session.setAttribute("cart.items",items);



/**Error here:  method get() and variable i are not known from
Cocoon's servlet



for (int i=0; i<items.size(); i++) {

items.get(i)

}



**/









Why do I receive the following two errors:

Line 174, column 58:  variable i not found in class
org.apache.cocoon.www.mount.essai.session3_xsp
Line 174, column 54:  method get() not found in class java.lang.Object


Is the syntax  I am using here not the same as the following, which is OK?







for (int i=1; i<11; i++)

{

i

}







Which is the difference between them?



Regards,

Cyril

- Original Message -
From: "Christian Haul" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 05, 2003 3:19 PM
Subject: Re: xsp session logicsheet


> On 05.Feb.2003 -- 02:56 PM, Cyril Vidal wrote:
> > Hello Christian,
> >
> > Thanks again for your help and your availibility.
> > Of course, I meant Session logicsheet and not ESQL one...Sorry...
> > I've tried to launch the code you've suggested:
> >
> > 
> >
> >  >
> > xmlns:xsp="http://apache.org/xsp";
> >
> > xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> >
> > xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> >
> > create-session="true">
>
> The class Vector is unknown here. Add
>
>   
>  java.util.Vector
>   
>
> in order to create an import statement.
>
> Add some markup here, otherwise the following code won't be inside the
> generate() method but would be expected to be a valid method
> declaration.
>
> 
> >
> > 
> >
> > Object items = ;
> >
> > if (items == null) items = new Vector(10,5);
> >
> > ((Vector) items).add();
> >
> > request.getSession().setAttribute(items);
> >
> > // logicsheet only supports setting Strings objects :-(
> >
> > // thus do it manually.
> >
> > 
>
> 
>
> > 
>
> > Regards,
> > Cyril.
> > PS: In the code, you've written:
> > request.getSession().setAttribute(items);
> >
> > shall we not write instead
> >
> > request.getSession().setAttribute("cart-item", items);
> >
> > as in the traditional java servlet?
>
> Absolutely, you are right. And the other poster is also right that
> there is a variable named "session" if the session logicsheet is
> used. Thus it suffices to write
>
>   session.setAttribute("cart.items", items);
>
> Chris.
>
> BTW when writing to the list you don't need to CC me -- it will end up
> in the same mailbox anyway (as duplicates).
>
> --
> C h r i s t i a n   H a u l
> [EMAIL PROTECTED]
> fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
>
> -
> Please check that your question  has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>
>
>



-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp session logicsheet

2003-02-05 Thread Christian Haul
On 05.Feb.2003 -- 02:56 PM, Cyril Vidal wrote:
> Hello Christian,
> 
> Thanks again for your help and your availibility.
> Of course, I meant Session logicsheet and not ESQL one...Sorry...
> I've tried to launch the code you've suggested:
> 
> 
> 
>  
> xmlns:xsp="http://apache.org/xsp";
> 
> xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> 
> xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> 
> create-session="true">

The class Vector is unknown here. Add

  
 java.util.Vector
  

in order to create an import statement.

Add some markup here, otherwise the following code won't be inside the
generate() method but would be expected to be a valid method
declaration. 


> 
> 
> 
> Object items = ;
> 
> if (items == null) items = new Vector(10,5);
> 
> ((Vector) items).add();
> 
> request.getSession().setAttribute(items);
> 
> // logicsheet only supports setting Strings objects :-(
> 
> // thus do it manually.
> 
> 



> 

> Regards,
> Cyril.
> PS: In the code, you've written:
> request.getSession().setAttribute(items);
> 
> shall we not write instead
> 
> request.getSession().setAttribute("cart-item", items);
> 
> as in the traditional java servlet?

Absolutely, you are right. And the other poster is also right that
there is a variable named "session" if the session logicsheet is
used. Thus it suffices to write

  session.setAttribute("cart.items", items);

Chris.

BTW when writing to the list you don't need to CC me -- it will end up
in the same mailbox anyway (as duplicates).

-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp session logicsheet

2003-02-05 Thread Cyril Vidal
Hello Christian,

Thanks again for your help and your availibility.
Of course, I meant Session logicsheet and not ESQL one...Sorry...
I've tried to launch the code you've suggested:



http://apache.org/xsp";

xmlns:xsp-session="http://apache.org/xsp/session/2.0";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";

create-session="true">



Object items = ;

if (items == null) items = new Vector(10,5);

((Vector) items).add();

request.getSession().setAttribute(items);

// logicsheet only supports setting Strings objects :-(

// thus do it manually.






But, I receive following error message:

type fatal

message Language Exception

description org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
session3_xsp: Line 78, column 6: illegal start of type Line 79, column 6:
illegal start of type Line 88, column 24: expected Line 88, column 14:
cannot access class getSession; file request\getSession.class not found Line
73, column 47: variable session not found in class
org.apache.cocoon.www.mount.essai.session3_xsp Line 0, column 0: 5 errors

sender org.apache.cocoon.servlet.CocoonServlet

source Cocoon servlet

stack-trace

org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
session3_xsp:
Line 78, column 6:  illegal start of type
Line 79, column 6:  illegal start of type
Line 88, column 24:   expected
Line 88, column 14:  cannot access class getSession; file
request\getSession.class not found
Line 73, column 47:  variable session not found in class
org.apache.cocoon.www.mount.essai.session3_xsp
Line 0, column 0:
5 errors

I've cheked out in the source code of the xsp file generated:

   68 /* User Class Declarations */

   70  Object items =

72   (
73  XSPSessionHelper.getSessionAttribute(session,
74  String.valueOf("cart.items"),
75 null)
76)
77  ;
78  if (items == null) items = new Vector(10,5);
79  ((Vector) items).add(

81  (
82  (XSPRequestHelper.getParameter(objectModel,
83   "item", null,
84null,
85null))
86)
87);

 I can't figure out why the line 78 throws an illegal start type...Do you
see what can be wrong?

Regards,
Cyril.
PS: In the code, you've written:
request.getSession().setAttribute(items);

shall we not write instead

request.getSession().setAttribute("cart-item", items);

as in the traditional java servlet?

I'm not sure...



-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




RE: xsp session logicsheet

2003-02-05 Thread FULEK Roman
Hi Cyril,
you do not have to use actions if you do not want :-)
As I said, when you use session namespace, there is always a variable
session there in the generated java code. You can access this session either
directly in xsp page from within  tags, or you can write your own
taglib. This taglib can then implicitly use session variable, though it will
never be declared there. What I propose to you is a kind of dirty
programming style, but as I understood you want a quick solution.

Try something like this, you have to experiment and always look at the
generated code:


http://apache.org/xsp";
xmlns:xsp-session="http://apache.org/xsp/session/2.0";
xmlns:xsp-request="http://apache.org/xsp/request/2.0"; create-session="true">


  
// beginning of the java code

try {
   // Cart items are maintained in the session object.
Vector items = (Vector)session.getAttribute("cart.items");
 if (items == null) { items = new Vector(10,5);}

   String item = req.getParameter("item");
   items.add(item);

   session.setAttribute("cart.items",items);
  

The list of items is: 





Roman


-Original Message-
From: Cyril Vidal [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 1:53 PM
To: [EMAIL PROTECTED]
Subject: Re: xsp session logicsheet



Hi Roman,

Indeed I've done this:


http://apache.org/xsp";

xmlns:xsp-session="http://apache.org/xsp/session/2.0";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";

create-session="true">





The list of items is: 



Your session was created: 





My problem is the following: I would like to add items to the attribute's
session 'cart.items'.
For the moment, the preceding code doesn't do this task.
When I call http://localhost:8080/cocoo/mount/try/session.xsp?item=3

I receive the following html result:
The list of items is: 3
Your session was created: Wed Feb 05 13:41:32 CET 2003

when I then call http://localhost:8080/cocoo/mount/try/session.xsp?item=5
The result is the following:
The list of items is: 5
Your session was created: Wed Feb 05 13:41:32 CET 2003

and of course, I would like
The list of items is: 3, 5
Your session was created: Wed Feb 05 13:41:32 CET 2003


What i would like to know : is it possible to achieve this task by using
Session Logicsheet by itself, does this Logicsheet provides this
functionnality?
If not, the alternative is also to use actions, as suggested in this thread
before?
Is a built-in action available for this, or do I have to build one from
scratch?

Any help or hint would help me,
Thanks,
Cyril.



> Hi Cyril,
> try adding
>
> xmlns:session="http://apache.org/xsp/session/2.0";
>
> namespace to your xsp page. Then have a look at the generated code.
> Basically you should see a java variable (object) named "session", with it
> you can do what you want. No need to declare it, cocoon does it for you.
> Roman
>
> -Original Message-
> From: Cyril Vidal [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 05, 2003 11:01 AM
> To: [EMAIL PROTECTED]
> Subject: Re: xsp session logicsheet
>
>
>
> Thanks for you response.
> hum, I guess actions are still a little bit too complex for me, regarding
my
> knowledge of Cocoon...
>
> Isn't it really possible to add merely values to the same session's
> attribute with the ESQL logicsheet? It   sounds  odd...
>
> Cyril.
>
> > Hi Cyril
> > Why don't use an action, I think it's better not to have too much Java
> code
> > in your xsp-pages.
> > In an action you can take your code as it is.
> > Cheers
> > Beat
> >
> > > Hi,
> > >
> > > I would like to deal with session through xsp, and serve as far as
> > > possible
> > > the same goal as with the following servlet: e.g put all the
parameters
> > > named 'item' in the object of type Vector 'items' bound to the current
> > > session, so that it would be possible to list at any time all of the
> items
> > > chosen so far by the client in his session.
> > >
> > >  public void doGet(HttpServletRequest req, HttpServletResponse res)
> > >throws ServletException, IOException {
> > > res.setContentType("text/html");
> > > PrintWriter out = res.getWriter();
> > >
> > > // Get the current session object, create one if necessary.
> > > HttpSession session = req.getSession(true);
> > >
> > > // Cart items are maintained in the session object.
> > >Vector items = (Vector)session.getAttribute("cart.items");
> > > if (items

Re: xsp session logicsheet

2003-02-05 Thread Christian Haul
On 05.Feb.2003 -- 11:00 AM, Cyril Vidal wrote:
> 
> Thanks for you response.
> hum, I guess actions are still a little bit too complex for me, regarding my
> knowledge of Cocoon...
> 
> Isn't it really possible to add merely values to the same session's
> attribute with the ESQL logicsheet? It   sounds  odd...

Er, no. But you probably didn't mean ESQL anyway.

You need to do it as you did it before: retrieve the value, add a new
element to it and then store it again.

> > > // Cart items are maintained in the session object.
> > >Vector items = (Vector)session.getAttribute("cart.items");
> > > if (items == null) { items = new Vector(10,5);}
> > >
> > >   String item = req.getParameter("item");
> > >   items.add(item);
> > >
> > >session.setAttribute("cart.items",items);

Would translate to

   
  Object items = ;
  if (items == null) items = new Vector(10,5);
  ((Vector) items).add();
  request.getSession().setAttribute(items); 
  // logicsheet only supports setting Strings objects :-(
  // thus do it manually.
   


Chris.
-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp session logicsheet

2003-02-05 Thread Cyril Vidal

Hi Roman,

Indeed I've done this:


http://apache.org/xsp";

xmlns:xsp-session="http://apache.org/xsp/session/2.0";

xmlns:xsp-request="http://apache.org/xsp/request/2.0";

create-session="true">





The list of items is: 



Your session was created: 





My problem is the following: I would like to add items to the attribute's
session 'cart.items'.
For the moment, the preceding code doesn't do this task.
When I call http://localhost:8080/cocoo/mount/try/session.xsp?item=3

I receive the following html result:
The list of items is: 3
Your session was created: Wed Feb 05 13:41:32 CET 2003

when I then call http://localhost:8080/cocoo/mount/try/session.xsp?item=5
The result is the following:
The list of items is: 5
Your session was created: Wed Feb 05 13:41:32 CET 2003

and of course, I would like
The list of items is: 3, 5
Your session was created: Wed Feb 05 13:41:32 CET 2003


What i would like to know : is it possible to achieve this task by using
Session Logicsheet by itself, does this Logicsheet provides this
functionnality?
If not, the alternative is also to use actions, as suggested in this thread
before?
Is a built-in action available for this, or do I have to build one from
scratch?

Any help or hint would help me,
Thanks,
Cyril.



> Hi Cyril,
> try adding
>
> xmlns:session="http://apache.org/xsp/session/2.0";
>
> namespace to your xsp page. Then have a look at the generated code.
> Basically you should see a java variable (object) named "session", with it
> you can do what you want. No need to declare it, cocoon does it for you.
> Roman
>
> -Original Message-
> From: Cyril Vidal [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 05, 2003 11:01 AM
> To: [EMAIL PROTECTED]
> Subject: Re: xsp session logicsheet
>
>
>
> Thanks for you response.
> hum, I guess actions are still a little bit too complex for me, regarding
my
> knowledge of Cocoon...
>
> Isn't it really possible to add merely values to the same session's
> attribute with the ESQL logicsheet? It   sounds  odd...
>
> Cyril.
>
> > Hi Cyril
> > Why don't use an action, I think it's better not to have too much Java
> code
> > in your xsp-pages.
> > In an action you can take your code as it is.
> > Cheers
> > Beat
> >
> > > Hi,
> > >
> > > I would like to deal with session through xsp, and serve as far as
> > > possible
> > > the same goal as with the following servlet: e.g put all the
parameters
> > > named 'item' in the object of type Vector 'items' bound to the current
> > > session, so that it would be possible to list at any time all of the
> items
> > > chosen so far by the client in his session.
> > >
> > >  public void doGet(HttpServletRequest req, HttpServletResponse res)
> > >throws ServletException, IOException {
> > > res.setContentType("text/html");
> > > PrintWriter out = res.getWriter();
> > >
> > > // Get the current session object, create one if necessary.
> > > HttpSession session = req.getSession(true);
> > >
> > > // Cart items are maintained in the session object.
> > >Vector items = (Vector)session.getAttribute("cart.items");
> > > if (items == null) { items = new Vector(10,5);}
> > >
> > >   String item = req.getParameter("item");
> > >   items.add(item);
> > >
> > >session.setAttribute("cart.items",items);
> > >
> > > out.println("SessionTracker
> > > modifie");
> > > out.println("Session Tracking Demo");
> > >
> > > // Print the current cart items.
> > > out.println("You currently have the following items in your
> > > cart:");
> > > if (items == null) {
> > >   out.println("None");
> > > }
> > > else {
> > >   out.println("");
> > >   for (int i = 0; i < items.size(); i++) {
> > > out.println("" + items.get(i));
> > >   }
> > >   out.println("");
> > > }
> > >
> > >
> > > out.println("");
> > >   }
> > > }
> > >
> > >  Below is the xsp i've written for the moment,: this is working fine,
> but
> > > does not do what I want: because each time the client chooses an item
&g

RE: xsp session logicsheet

2003-02-05 Thread FULEK Roman
Hi Cyril,
try adding

xmlns:session="http://apache.org/xsp/session/2.0";  

namespace to your xsp page. Then have a look at the generated code.
Basically you should see a java variable (object) named "session", with it
you can do what you want. No need to declare it, cocoon does it for you.
Roman

-Original Message-
From: Cyril Vidal [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: Re: xsp session logicsheet



Thanks for you response.
hum, I guess actions are still a little bit too complex for me, regarding my
knowledge of Cocoon...

Isn't it really possible to add merely values to the same session's
attribute with the ESQL logicsheet? It   sounds  odd...

Cyril.

> Hi Cyril
> Why don't use an action, I think it's better not to have too much Java
code
> in your xsp-pages.
> In an action you can take your code as it is.
> Cheers
> Beat
>
> > Hi,
> >
> > I would like to deal with session through xsp, and serve as far as
> > possible
> > the same goal as with the following servlet: e.g put all the parameters
> > named 'item' in the object of type Vector 'items' bound to the current
> > session, so that it would be possible to list at any time all of the
items
> > chosen so far by the client in his session.
> >
> >  public void doGet(HttpServletRequest req, HttpServletResponse res)
> >throws ServletException, IOException {
> > res.setContentType("text/html");
> > PrintWriter out = res.getWriter();
> >
> > // Get the current session object, create one if necessary.
> > HttpSession session = req.getSession(true);
> >
> > // Cart items are maintained in the session object.
> >Vector items = (Vector)session.getAttribute("cart.items");
> > if (items == null) { items = new Vector(10,5);}
> >
> >   String item = req.getParameter("item");
> >   items.add(item);
> >
> >session.setAttribute("cart.items",items);
> >
> > out.println("SessionTracker
> > modifie");
> > out.println("Session Tracking Demo");
> >
> > // Print the current cart items.
> > out.println("You currently have the following items in your
> > cart:");
> > if (items == null) {
> >   out.println("None");
> > }
> > else {
> >   out.println("");
> >   for (int i = 0; i < items.size(); i++) {
> > out.println("" + items.get(i));
> >   }
> >   out.println("");
> > }
> >
> >
> > out.println("");
> >   }
> > }
> >
> >  Below is the xsp i've written for the moment,: this is working fine,
but
> > does not do what I want: because each time the client chooses an item
and
> > pass it via the parameter 'item', instead of being added in the object
> > cart.items, its value overrides this of the preceding parameter.
> >
> > 
> >
> >  >
> > xmlns:xsp="http://apache.org/xsp";
> >
> > xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> >
> > xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> >
> > create-session="true">
> >
> > 
> >
> >  > name="item"/>
> >
> > You currently have the following items in your cart:
> > 
> >
> > 
> >
> > Your session was created:  > as="string"/>
> >
> > 
> >
> > 
> >
> > Some of you would know how I can improve my code? Indeed, I would like
> > cart.items to be like a Vector, so that it would be possible to put
merely
> > values onto it.
> > Thanks in advance for your help,
> > Cyril.
> >
> >
> >
> > -
> > Please check that your question  has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail:   <[EMAIL PROTECTED]>
> >
>
> --
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
>
>
> -
> Please check that your question  has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>
>
>



-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




Re: xsp session logicsheet

2003-02-05 Thread Cyril Vidal

Thanks for you response.
hum, I guess actions are still a little bit too complex for me, regarding my
knowledge of Cocoon...

Isn't it really possible to add merely values to the same session's
attribute with the ESQL logicsheet? It   sounds  odd...

Cyril.

> Hi Cyril
> Why don't use an action, I think it's better not to have too much Java
code
> in your xsp-pages.
> In an action you can take your code as it is.
> Cheers
> Beat
>
> > Hi,
> >
> > I would like to deal with session through xsp, and serve as far as
> > possible
> > the same goal as with the following servlet: e.g put all the parameters
> > named 'item' in the object of type Vector 'items' bound to the current
> > session, so that it would be possible to list at any time all of the
items
> > chosen so far by the client in his session.
> >
> >  public void doGet(HttpServletRequest req, HttpServletResponse res)
> >throws ServletException, IOException {
> > res.setContentType("text/html");
> > PrintWriter out = res.getWriter();
> >
> > // Get the current session object, create one if necessary.
> > HttpSession session = req.getSession(true);
> >
> > // Cart items are maintained in the session object.
> >Vector items = (Vector)session.getAttribute("cart.items");
> > if (items == null) { items = new Vector(10,5);}
> >
> >   String item = req.getParameter("item");
> >   items.add(item);
> >
> >session.setAttribute("cart.items",items);
> >
> > out.println("SessionTracker
> > modifie");
> > out.println("Session Tracking Demo");
> >
> > // Print the current cart items.
> > out.println("You currently have the following items in your
> > cart:");
> > if (items == null) {
> >   out.println("None");
> > }
> > else {
> >   out.println("");
> >   for (int i = 0; i < items.size(); i++) {
> > out.println("" + items.get(i));
> >   }
> >   out.println("");
> > }
> >
> >
> > out.println("");
> >   }
> > }
> >
> >  Below is the xsp i've written for the moment,: this is working fine,
but
> > does not do what I want: because each time the client chooses an item
and
> > pass it via the parameter 'item', instead of being added in the object
> > cart.items, its value overrides this of the preceding parameter.
> >
> > 
> >
> >  >
> > xmlns:xsp="http://apache.org/xsp";
> >
> > xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> >
> > xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> >
> > create-session="true">
> >
> > 
> >
> >  > name="item"/>
> >
> > You currently have the following items in your cart:
> > 
> >
> > 
> >
> > Your session was created:  > as="string"/>
> >
> > 
> >
> > 
> >
> > Some of you would know how I can improve my code? Indeed, I would like
> > cart.items to be like a Vector, so that it would be possible to put
merely
> > values onto it.
> > Thanks in advance for your help,
> > Cyril.
> >
> >
> >
> > -
> > Please check that your question  has not already been answered in the
> > FAQ before posting. 
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail:   <[EMAIL PROTECTED]>
> >
>
> --
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
>
>
> -
> Please check that your question  has not already been answered in the
> FAQ before posting. 
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>
>
>



-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>