Forums Register Login

Stateful Session and JSP

+Pie Number of slices to send: Send
Hello,
Can someone give me an example of the best way to use a stateful session in a jsp. I need the statefull session to store the data that is on a form. I understand how to create the jsp and session bean, but I don't know the best way to tie the two together. Do you make direct calls from the jsp to the stateful session bean or do you just a javabean or is there another way?
Thanks,
Trish
+Pie Number of slices to send: Send
u can access the session bean's business logic method via the remote interface.u can write the same way in jsp as u wud've written in a .java class file.
'm writing a simple example .jsp code which maintains the page count.
<%@ page language="java" import="javax.ejb.*,javax.naming.*,java.io.*,java.util.*,java.text.*" %>
<%<br /> <br /> int count=0;<br /> try<br /> {<br /> Properties prop=System.getProperties();<br /> prop.put(Context.INITIAL_CONTEXT_FACTORY,<br /> "weblogic.jndi.WLInitialContextFactory");<br /> Context ctx= new InitialContext(prop);<br /> StateFullHome home =(StateFullHome) ctx.lookup("MyStateFullHome");<br /> int i=1;<br /> StateFull home =home.create(i);<br /> >%
<HTML>
<BODY>
<H2>U have Entered this page <%home.count()%> number of times</H2>
</BODY>
</HTML>
<%<br /> }<br /> catch(Exception e)<br /> {<br /> <br /> }<br /> <br /> %>
+Pie Number of slices to send: Send
oops sorry,the code seems to've left out somewhere.
well........here it is
< %@ page language="java" import="javax.ejb.*,javax.naming.*,java.io.*,java.util.*,java.text.*" %>
< %<br /> <br /> int count=0;<br /> try<br /> {<br /> Properties prop=System.getProperties();<br /> prop.put(Context.INITIAL_CONTEXT_FACTORY,<br /> "weblogic.jndi.WLInitialContextFactory");<br /> Context ctx= new InitialContext(prop);<br /> StateFullHome home =(StateFullHome) ctx.lookup("MyStateFullHome");<br /> int i=1;<br /> StateFull home =home.create(i);<br /> >%
< HTML >
< BODY >
< H2 >U have Entered this page < %home.count()%> number of times< /H2>
< /BODY>
< /HTML>
< %<br /> }<br /> catch(Exception e)<br /> {<br /> <br /> }<br /> <br /> %>

[This message has been edited by Thomas Paul (edited December 10, 2001).]
Fixed for formatting
[This message has been edited by Thomas Paul (edited December 10, 2001).]
+Pie Number of slices to send: Send
Thanks monojit choudhury I appreciate it. That helps!
this is supposed to be a surprise, but it smells like a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1238 times.
Similar Threads
How to persist a Stateless Session Bean over several jsp pages?
Tricky question (How to pass javax.ejb.Handle)
As i am drawing sequence diagram for prepare itinerary...
Stateful Session Bean
Registration with steps
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:57:38.