You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Quittenton <ji...@hotmail.com> on 2001/07/04 17:55:01 UTC

Forwarding/redirecting to action mappings rather than directly to JSPs

Hi

I have an action class from which I need to forward to another action mapping (rather than directly to a JSP), and I have managed to get this working by setting up a global forward to an absolute path with rediredt set to true as follows:

  <global-forwards>
    <forward name="myForward" path="http://myServer/myDB/myApp/myMapping.do" redirect="true"/>
  </global-forwards>

Apart from the inconvenience of having to change the path in struts-config.xml for each deployment, this was fine.

Now however I am trying to deploy to a 2 different servers (to which requests are forwarded to from a load balancing server). Both these servers share the same database (and therefore the same war file) and so the above forward will fail when accessed from the other server.

The best way to do this would be to use a relative path, but this errors at runtime saying the path must be absolute. Another way would be to add the forward dynamically to the ActionServlet at runtime but I don't know how to get a reference to the servlet instance so I can call its methods.

Any help is appreciated

Jim

Re: Forwarding/redirecting to action mappings rather than directly to JSPs

Posted by Jim Quittenton <ji...@hotmail.com>.
The relative path redirect issue is likely caused by Silverstream (as of 3.7.1) not fully implementing the servlet 2.2 spec. If so I'm left with trying to add the forwards to the actionservlet at runtime.
  ----- Original Message ----- 
  From: Jim Quittenton 
  To: struts-user@jakarta.apache.org 
  Sent: Wednesday, July 04, 2001 4:55 PM
  Subject: Forwarding/redirecting to action mappings rather than directly to JSPs


  Hi

  I have an action class from which I need to forward to another action mapping (rather than directly to a JSP), and I have managed to get this working by setting up a global forward to an absolute path with rediredt set to true as follows:

    <global-forwards>
      <forward name="myForward" path="http://myServer/myDB/myApp/myMapping.do" redirect="true"/>
    </global-forwards>

  Apart from the inconvenience of having to change the path in struts-config.xml for each deployment, this was fine.

  Now however I am trying to deploy to a 2 different servers (to which requests are forwarded to from a load balancing server). Both these servers share the same database (and therefore the same war file) and so the above forward will fail when accessed from the other server.

  The best way to do this would be to use a relative path, but this errors at runtime saying the path must be absolute. Another way would be to add the forward dynamically to the ActionServlet at runtime but I don't know how to get a reference to the servlet instance so I can call its methods.

  Any help is appreciated

  Jim

Re: Lookup ejb's in action classes

Posted by Pham Thanh Quan <qu...@sdcgrp.com>.
MessageYou must have the following in your web.xml file
 
<ejb-ref>

  <ejb-ref-name>ejbUserManagement</ejb-ref-name>

  <ejb-ref-type>Entity(or Session)</ejb-ref-type>

  <home>home bean here (e.g. project.package.UserManagementHome)</home>

  <remote>remote here (e.g. project.package.UserManagement)</remote>

</ejb-ref>



after that, you must also have the following in the server-specific config file (e.g. in weblogic, it is weblogic.xml)



<ejb-reference-description>

  <ejb-ref-name>ejbUserManagement</ejb-ref-name>

  <jndi-name>jndi name of your bean</jndi-name>

</ejb-reference-description>



Or for more simple, you should use this instead :

Object homeObject = ctx.lookup("JNDI name of your bean here");
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject, UserManagementHome.class);
  ----- Original Message ----- 
  From: Jan Heise 
  To: johann@maskina.com 
  Cc: struts 
  Sent: Thursday, July 05, 2001 12:10 AM
  Subject: AW: Lookup ejb's in action classes


  hi,
   
  i use the jndi-browser that comes with sun's jndi-examples once in a while
  to check if my context contains what i expect to. on my last project with
  orion (but i did not use struts) i also set
   
  java.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory
  java.naming.provider.url=ormi://localhost/appname
  java.naming.security.principal=user here
  java.naming.security.credentials=password here
   
  even though i call this from inside my jsps and it should possibly be not necessary - but it works.

  hope that helps.
   
  jan
  --
  Jan Heise / Tel: +49-170-4803237 / E-Mail: jan@janheise.de 

    -----Ursprüngliche Nachricht-----
    Von: joi [mailto:johann@maskina.com]
    Gesendet: Mittwoch, 4. Juli 2001 18:20
    An: struts-user@jakarta.apache.org
    Betreff: Lookup ejb's in action classes


    I have a problem performin lookup on my ejb's in struts action classes. I always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml and web.xml are correct. Is this a common  problem accessing the Context through the struts action classes? 
    I'm using orion 1.5.2 app. server.
     
    Code from my action class..
    ..
    Context ctx = new InitialContext();
    Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement"); //throws NameNotFoundException here.
    home = (UserManagementHome)PortableRemoteObject.narrow(homeObject, UserManagementHome.class);
    ..
    As I said before I am pretty sure that my ejb-jar.xml and web.xml are correct so what could be causing this? I've tried almost everything I can think of..
    Any ideas..
     

AW: Lookup ejb's in action classes

Posted by Jan Heise <he...@pnpconsult.com>.
Messagehi,

i use the jndi-browser that comes with sun's jndi-examples once in a while
to check if my context contains what i expect to. on my last project with
orion (but i did not use struts) i also set

java.naming.factory.initial=com.evermind.server.ApplicationClientInitialCont
extFactory
java.naming.provider.url=ormi://localhost/appname
java.naming.security.principal=user here
java.naming.security.credentials=password here

even though i call this from inside my jsps and it should possibly be not
necessary - but it works.

hope that helps.

jan
--
Jan Heise / Tel: +49-170-4803237 / E-Mail: jan@janheise.de

  -----Ursprungliche Nachricht-----
  Von: joi [mailto:johann@maskina.com]
  Gesendet: Mittwoch, 4. Juli 2001 18:20
  An: struts-user@jakarta.apache.org
  Betreff: Lookup ejb's in action classes


  I have a problem performin lookup on my ejb's in struts action classes. I
always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml and
web.xml are correct. Is this a common  problem accessing the Context through
the struts action classes?
  I'm using orion 1.5.2 app. server.

  Code from my action class..
  ..
  Context ctx = new InitialContext();
  Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement");
//throws NameNotFoundException here.
  home = (UserManagementHome)PortableRemoteObject.narrow(homeObject,
UserManagementHome.class);
  ..
  As I said before I am pretty sure that my ejb-jar.xml and web.xml are
correct so what could be causing this? I've tried almost everything I can
think of..
  Any ideas..


Lookup ejb's in action classes

Posted by joi <jo...@maskina.com>.
I have a problem performin lookup on my ejb's in struts action classes.
I always get NameNotFoundException. I'm pretty sure that my ejb-jar.xml
and web.xml are correct. Is this a common  problem accessing the Context
through the struts action classes? 
I'm using orion 1.5.2 app. server.
 
Code from my action class..
..
Context ctx = new InitialContext();
Object homeObject = ctx.lookup("java:comp/env/ejbUserManagement");
//throws NameNotFoundException here.
home = (UserManagementHome)PortableRemoteObject.narrow(homeObject,
UserManagementHome.class);
..
As I said before I am pretty sure that my ejb-jar.xml and web.xml are
correct so what could be causing this? I've tried almost everything I
can think of..
Any ideas..