I am also trying to work out an overall architecture using JSP and EJB. 
Although I cannot answer your question directly, here's what I'm
thinking for my system.  Perhaps others will comment on this.  

I'm planning to use a servlet to handle all http requests from
browsers.  The servlet will dispatch the request internally to a
processing object for that request.  The processing object will make a
request or requests to the EJB layer, sometimes to SessionBeans and
sometimes to EntityBeans.  The servlet will then forward the request to
a JSP for display of the output.  In order to communicate the response
to the display JSP, the servlet will add one or more response objects to
the servlet session so they can be used as beans by the JSP.  AFAIK (but
I haven't tried this yet) it shouldn't matter whether the bean is a
local JavaBean that is created by the servlet from its response obtained
from the EBJ layer, a remote object communicated back from EJB as the
response using serialization, or an EntityBean remote object.  As long
as it adheres to the JavaBean requirements of JSP, the JSP page should
be able to display the response. 

btw, I'm using a servlet to process responses because I think it
provides a more unified way of dealing with what responses are legal in
whatever state the user's session happens to be in, and what next page
should be displayed.

I'm sure that custom tags have a place in this architecture, as well, to
further insulate the html generation done by the JSPs from the Java code
used to process responses and generate dynamic content, but I haven't
gotten this far as yet.

Hope this helps, and I'd be interested in hearing some comments about my
proposed architecture.

Thanks,

Rick Horowitz

Tung Bui wrote:
> 
> Hi, as part of my learning, I tried to implement a dynamic page as follow:
> JSP<->Java Bean<->EJB<->JDBC. I got it works as intended however with a
> hack. Within the my Java Bean, in order to look up the EJB bean
> successfully, I have to hard code the context info as follow:
>     Hashtable env = new Hashtable();
>     env.put(Context.INITIAL_CONTEXT_FACTORY,
>             "com.evermind.server.ApplicationClientInitialContextFactory");
>     env.put(Context.PROVIDER_URL,"ormi://localhost/linkcontent");
>     env.put(Context.SECURITY_PRINCIPAL,"xxxx");
>     env.put(Context.SECURITY_CREDENTIALS,"xxxx");
>     Context ctx = new InitialContext(env);
> Which is not an ideal way. I'm having trouble from figuring out how to set
> these information up so that I do not have to hard code this way. Any idea?
> 
> Thanks,
> Tung

Reply via email to