struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Brown <adrianjonbr...@yahoo.com.au>
Subject Re: Problem with Proxy Pass
Date Fri, 23 Aug 2002 01:24:30 GMT
Hi Billy,

For that problem, I'd go off the locale required by
the user's request, and use the getLocale() method.

You can change the locale at the user's request using
the Action.LOCALE_KEY.

This doesn't help you distinguishing a .com from a
.com.de address, for that I could only suggest you
proxy pass to a different part of your application for
the .com.de address, eg.

ProxyPass www.myDomain.com
/192.168.0.8:8080/regular.do
ProxyPass www.myDomain.com.de /192.168.0.8:8080/de.do

and have the de.do action set the locale properly,
then forward to the regular.do action.

Adrian

 --- Billy Ng <evebill8@hotmail.com> wrote: > Thank
you for your tips.  For the host name problem.
>  Hard coding the host 
> name in web.xml or Resources file seems to solve the
> problem.  However, if I 
> need to set the locale depends on the host name, it
> will be a problem.  For 
> example, I have the site that displays German and
> English.  The host names 
> will be www.myDomain.com and myDomain.co.de.  Since
> the Apache porxy pass 
> the both requests to 192.168.0.8:8080, from the
> request.getServerName(), I 
> will get the 192.168.0.8:8080 so that I cannot tell
> what locale to set.  I 
> think I need to do the port forwarding on the router
> level or using mod_jk 
> to put Apache and Tomcat together.  Any other
> inputs?
> 
> Billy Ng
> 
> >From: Adrian Brown <adrianjonbrown@yahoo.com.au>
> >Reply-To: "Struts Users Mailing List"
> <struts-user@jakarta.apache.org>
> >To: Struts Users Mailing List
> <struts-user@jakarta.apache.org>
> >Subject: Re: Problem with Proxy Pass
> >Date: Thu, 22 Aug 2002 16:55:21 +1000 (EST)
> >
> >Just following up on myself,
> >
> >if you like, a better way to get the init
> parameters
> >would be through setting up config parameters by
> >putting the following under the <web-app> element
> in
> >your web.xml:
> >
> >   <context-param>
> >    
> <param-name>useAlternateServerName</param-name>
> >     <param-value>true</param-value>
> >   </context-param>
> >   <context-param>
> >     <param-name>alternateServerName</param-name>
> >     <param-value>www.myDomain.com.au</param-value>
> >   </context-param>
> >
> >and then reference them like this in the
> >BaseTag.doStartTag() method:
> >
> >	String value =
>
>pageContext.getServletContext().getInitParameter("useAlternateServerName");
> >
> >and
> >
> >	String value =
>
>pageContext.getServletContext().getInitParameter("alternateServerName");
> >
> >instead of using getServletConfig(), and adding the
> >extra servlet (jsp) in your web.xml.
> >
> >This has the advantage of being accessible from
> within
> >your action servlet whenever you like (just delete
> the
> >'pageContext' bit).
> >
> >Hope that is not to confusing!
> >
> >Adrian
> >
> >  --- Adrian Brown <adrianjonbrown@yahoo.com.au>
> wrote:
> > > Hi Billy,
> > >
> > > What I had in mind was not really a silver
> bullet,
> > > but
> > > rather doing something like looking for a server
> > > property set in your web.xml file for the
> *actual*
> > > name of the server, and using that instead of
> > >
> > > request.getServerName()
> > >
> > > in the
> > >
> org.apache.struts.taglib.html.BaseTag.doStartTag().
> > >
> > > Basically, replace the line in the doStartTag():
> > >
> > > buf.append(request.getServerName());
> > >
> > > with the following:
> > >
> > >     String serverName = request.getServerName();
> > >
> > > 	String value =
> > >
>
>pageContext.getServletConfig().getInitParameter("useAlternateServerName");
> > >
> > >     boolean useAlternateServerName = false;
> > > 	if (value != null) {
> > > 	    if (value.equalsIgnoreCase("true") ||
> > > 	        value.equalsIgnoreCase("yes"))
> > > 	        useAlternateServerName = true;
> > > 	}
> > >     if (useAlternateServerName)
> > >         serverName =
> > >
>
>pageContext.getServletConfig().getInitParameter("alternateServerName");
> > >     buf.append(serverName);
> > >
> > > and then in your web.xml, put in the following
> > > servlet
> > > info:
> > >
> > >   <servlet>
> > >     <servlet-name>
> > >         jsp
> > >     </servlet-name>
> > >     <servlet-class>
> > >         org.apache.jasper.servlet.JspServlet
> > >     </servlet-class>
> > >     <init-param>
> > >
> > > <param-name>useAlternateServerName</param-name>
> > >       <param-value>true</param-value>
> > >     </init-param>
> > >     <init-param>
> > >      
> <param-name>alternateServerName</param-name>
> > >      
> <param-value>www.myDomain.com.au</param-value>
> > >
> > >     </init-param>
> > >   </servlet>
> > >   <servlet-mapping>
> > >       <servlet-name>
> > >           jsp
> > >       </servlet-name>
> > >       <url-pattern>
> > >           *.jsp
> > >       </url-pattern>
> > >   </servlet-mapping>
> > >
> > > This is necessary to put some init parameters
> into
> > > the
> > > servlet handling your jsps, and it is Tomcat
> > > specific.
> > > I have not found a method by which JSP Tags can
> > > access
> > > init parameters via servlets other than 'jsp'
> (eg.
> > > action is inaccessible). If anyone has any
> > > workarounds
> > > I'd be very interested.
> > >
> > > I notice you also reported problems with getting
> the
> > > right context through
> > >
> > > request.getContextPath()
> > >
> > > Same again - you can re-use the code above with
> a
> > > couple of changes (eg. consideration of port
> number)
> > > to check you have the desired context (alternate
> or
> > > regular). Note the init params may have to
> appear in
> > > the action servlet's context if you are calling
> > > getContextPath() within it.
> > >
> > > By deploying one version of your code on your
> > > proxied
> > > server and another on your test with
> > > useAlternateServerName set to false (or simply
> left
> > > out) you can control what server names your
> servlet
> > > believes it is called.
> > >
> > > The problem I have not surmounted yet is how to
> > > interpret when a particular call is going
> through
> > > your
> > > proxy, and when it is not, though you could do
> this
> > > by
> > > perhaps setting up your app to listen on two
> ports -
> > > one for the proxied requests and one for local
> ones,
> > > that way you could tell them apart. But that I
> > > haven't
> > > done yet (I just deploy the same app to another
> box
> 
=== message truncated === 

http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message