Bill Burke | 1 Jul 2002 14:43

RE: Load Balancer/Failover ?

Also, Greg has implemented AJP13 integration in 4.1, right Jan?  So you can
use Apache/mod_jk as your load-balancer.

> -----Original Message-----
> From: Jan Bartel [mailto:janb <at> mortbay.com]
> Sent: Sunday, June 30, 2002 3:12 PM
> To: jetty-support <at> yahoogroups.com
> Subject: Re: [jetty-support] Load Balancer/Failover ?
>
>
> Hi,
>
> A load balancer was included with the 4.0.0 release, however I
> believe that Greg was looking for some more feedback on it to
> help mature it (so I encourage you to have a go!).
>
> Here's a copy of some usage instructions Greg gave on an
> earlier posting:
>
>  >>It is now included in the RC2 release, but you will have to re
>  >>build it with jdk1.4
>  >>
>  >>Usage - java org.mortbay.loadbalancer.Balancer [[host]:port ... ]
>  >>- [[server]:port ... ]
>  >>
>  >>So if you wanted to listen on all interfaces on port 80 and share load
>  >>to port 8080 on 1.2.3.4 and 4.3.2.1 you would say:
>  >>
>  >>java org.mortbay.loadbalancer.Balancer :80 - 1.2.3.4:8080 4.3.2.1:8080
>  >>
(Continue reading)

tacnaboyz | 1 Jul 2002 22:23
Picon
Favicon

Forwarding request to CGI program?

Hello,
Is this possible in Jetty?  A quick test gave me an "Internal Server 
Error".  Before I spend too much time investigating, I'm hoping maybe 
someone can tell me if it's even possible.  The CGI program simly 
returns HTML to the client and I want to control access and request 
paramaters to this CGI program via a servlet... so 
Response.sendRedirect will not be sufficient in this case.  

Here's what I tried in Jetty 4.1D2 (JDK 1.3),

getServletContext().getRequestDispatcher("/cgi-
bin/my_cgi_prog.exe").forward(request,response);

It might be just a context/path related problem, but not sure exactly 
what.

Thank you!

For the latest information about Jetty, please see http://jetty.mortbay.org

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

Jan Bartel | 1 Jul 2002 22:41

Re: Load Balancer/Failover ?

Someone is paying attention ;-). Yup, 4.1 comes with a
AJP13 listener, permitting integration with Apache and others.

Jan

Bill Burke wrote:
> Also, Greg has implemented AJP13 integration in 4.1, right Jan?  So you can
> use Apache/mod_jk as your load-balancer.
> 
> 
>>-----Original Message-----
>>From: Jan Bartel [mailto:janb <at> mortbay.com]
>>Sent: Sunday, June 30, 2002 3:12 PM
>>To: jetty-support <at> yahoogroups.com
>>Subject: Re: [jetty-support] Load Balancer/Failover ?
>>
>>
>>Hi,
>>
>>A load balancer was included with the 4.0.0 release, however I
>>believe that Greg was looking for some more feedback on it to
>>help mature it (so I encourage you to have a go!).
>>
>>Here's a copy of some usage instructions Greg gave on an
>>earlier posting:
>>
>> >>It is now included in the RC2 release, but you will have to re
>> >>build it with jdk1.4
>> >>
>> >>Usage - java org.mortbay.loadbalancer.Balancer [[host]:port ... ]
(Continue reading)

Jules Gosnell | 1 Jul 2002 22:47

Re: Forwarding request to CGI program?

tacnaboyz wrote:
> Hello,
> Is this possible in Jetty?  A quick test gave me an "Internal Server 
> Error".  Before I spend too much time investigating, I'm hoping maybe 
> someone can tell me if it's even possible.  The CGI program simly 
> returns HTML to the client and I want to control access and request 
> paramaters to this CGI program via a servlet... so 
> Response.sendRedirect will not be sufficient in this case.  
> 
> Here's what I tried in Jetty 4.1D2 (JDK 1.3),
> 
> getServletContext().getRequestDispatcher("/cgi-
> bin/my_cgi_prog.exe").forward(request,response);
> 
> It might be just a context/path related problem, but not sure exactly 
> what.
> 
> Thank you!

Can we have a little more of the stack trace/log ?

Have you set up the CGI servlet ?

Jules

> 
> 
> For the latest information about Jetty, please see http://jetty.mortbay.org
> 
>  
(Continue reading)

tacnaboyz | 1 Jul 2002 23:34
Picon
Favicon

Re: Forwarding request to CGI program?

Thank you for your reply.  I'm just evaluating Jetty to see if 
fulfills my requirements. I didn't expect you to help me with my 
specific problem.... but if you don't mind... here goes ;)

I'm not really knowledgeable on the configuration.  I probably just 
don't have my context mappings set up for it.  I basically downloaded 
it, stuck the forwarding servlet in the 
"Jetty-4.1.D2\demo\webapps\examples\WEB-INF\classes" directory and 
tried to hit it 
with "http://localhost:8080/examples/servlet/forwardtest"

I kind of figured I've have to set up something in a web.xml, but 
don't know what/how.  Anyway, yes, was able to execute the CGI 
program directly by using "http://localhost:8080/cgi-
bin/my_cgi_prog.exe".  That works fine.

You asked for the stack trace.  Hopefully this is what you're talking 
about (taken from console).  Thanks!

-------------------------------------

15:16:42.791 EVENT  Dynamic load 'mapper' at /servlet/forwardtest
Exception java.lang.NullPointerException
15:16:42.811 WARN!! Servlet Exception 
for /examples/servlet/forwardtest
java.lang.NullPointerException
        at mapper.doGet(forwardtest.java:19)
        at javax.servlet.http.HttpServlet.service
(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service
(Continue reading)

Brett Sealey | 2 Jul 2002 00:09

Re: Re: Forwarding request to CGI program?

You probably should be using the / context instead of the default one for
your servlet (which is /examples I believe).

The javadoc for getRequestDispatcher says:
     * <p>The pathname must begin with a "/" and is interpreted as relative
     * to the current context root.  Use <code>getContext</code> to obtain
     * a <code>RequestDispatcher</code> for resources in foreign contexts.
     * This method returns <code>null</code> if the <code>ServletContext</code>
     * cannot return a <code>RequestDispatcher</code>.

Another option would be to add the cgi mapping to the example context by
editing Jetty-4.1.D2\demo\webapps\examples\WEB-INF\web.xml, in which case
you should be able to use
http://localhost:8080/examples/cgi-bin/my_cgi_prog.exe

This should be enough info to get you going.

Note that CGI handling is implemented as a Servlet. Forwarding to Servlets
is very fundamental behaviour - so the odds are well in your favour
here...

Brett

On Mon, 1 Jul 2002, tacnaboyz wrote:

> Thank you for your reply.  I'm just evaluating Jetty to see if 
> fulfills my requirements. I didn't expect you to help me with my 
> specific problem.... but if you don't mind... here goes ;)
> 
> I'm not really knowledgeable on the configuration.  I probably just 
(Continue reading)

xx | 2 Jul 2002 06:04

Problem forwarding to files within WEB-INF

(using v3.1.8)

I would like run every single URL through a master "controller" 
servlet (for security reasons, etc.) I've moved all of my jsps and 
static content under WEB-INF, so nothing is directly accessible by a 
browser. However, when I try to use a RequestDispatcher to forward 
to WEB-INF, I get an infinite loop.

My servlet mapping is:
  <servlet-mapping>
    <servlet-name>ControlServlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

My very simple doGet method:
  RequestDispatcher rd =
    getServletContext().getRequestDispatcher("/WEB-INF/test.html");
  rd.forward(request, response);

I'm pretty sure Jetty supports something like this:
  http://www.servlets.com/archive/servlet/ReadMsg?
msgId=175174&listName=advanced-servlets

Thanks,
Chris

For the latest information about Jetty, please see http://jetty.mortbay.org

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

(Continue reading)

WATSON Matt | 2 Jul 2002 06:30

RE: Problem forwarding to files within WEB-INF

> I would like run every single URL through a master "controller" 
> servlet (for security reasons, etc.) I've moved all of my jsps and 
> static content under WEB-INF, so nothing is directly accessible by a 
> browser. However, when I try to use a RequestDispatcher to forward 
> to WEB-INF, I get an infinite loop.
> 
> My servlet mapping is:
>   <servlet-mapping>
>     <servlet-name>ControlServlet</servlet-name>
>     <url-pattern>/*</url-pattern>
>   </servlet-mapping>

I have done something like this, but you can't have your "controller"
servlet using the pattern of "/*" as it catches everything. Thus the
RequestDispatcher is looking up the resource of the path your try to forward
to (In this case, "/WEB-INF/test.html") and finds that your controller
servlet is serving that path. Thus it recurses ad infinitum.

You need to put your "controller" servlet on an explicit path that doesn't
have it handling /WEB-INF, then it should work fine.

Matt

IMPORTANT NOTICE:
This e-mail and any attachment to it is intended only to be read or used by
the named addressee.  It is confidential and may contain legally privileged
information.  No confidentiality or privilege is waived or lost by any
mistaken transmission to you.  If you receive this e-mail in error, please
immediately delete it from your system and notify the sender.  You must not
disclose, copy or use any part of this e-mail if you are not the intended
(Continue reading)

Chris Haynes | 2 Jul 2002 09:48
Picon

Re: Problem forwarding to files within WEB-INF

I avoided the loop by serving my own files - not a very pretty
approach.
But as the only 'file' I needed to serve was a 'welcome' which led
into an all-servlet environment with a few simple, static graphics
(which I could cache in RAM while I was at it) - this worked for me.

There might be a way to re-use some of the Jetty classes to do this
file serving, by-passing the dispatcher which leads to the loop - but,
of course, that would then be non-portable.

Chris Haynes

----- Original Message -----
From: "xx" <chris <at> nokleberg.com>
To: <jetty-support <at> yahoogroups.com>
Sent: Tuesday, July 02, 2002 5:04 AM
Subject: [jetty-support] Problem forwarding to files within WEB-INF

> (using v3.1.8)
>
> I would like run every single URL through a master "controller"
> servlet (for security reasons, etc.) I've moved all of my jsps and
> static content under WEB-INF, so nothing is directly accessible by a
> browser. However, when I try to use a RequestDispatcher to forward
> to WEB-INF, I get an infinite loop.
>
> My servlet mapping is:
>   <servlet-mapping>
>     <servlet-name>ControlServlet</servlet-name>
>     <url-pattern>/*</url-pattern>
(Continue reading)

xx | 2 Jul 2002 11:46

Re: Problem forwarding to files within WEB-INF

--- In jetty-support <at> y..., WATSON Matt <mattw <at> m...> wrote:
> You need to put your "controller" servlet on an explicit path
> that doesn't have it handling /WEB-INF, then it should work fine.

Thanks for the tip, but I don't want to have a specific path for the 
servlets. Wouldn't it be nice if as part of the url-pattern you 
could say "everything except /WEB-INF/*"?

...Along those lines, I've added the following to 
org.mortbay.jetty.servlet.ServletHandler.getHolderEntry:

  Map.Entry entry = _servletMap.getMatch(pathInContext);
+ if (entry != null && entry.getKey().equals("/*") &&
+     pathInContext.startsWith("/WEB-INF/"))
+     return null;

This prevents "/*" from matching forwards to WEB-INF. It still 
allows explicit url-mappings to /WEB-INF/what/ever, if you want 
(although that's probably a Bad Idea anyway).

I've thought about this a while and I don't think it could break 
anything. I'd really appreciate it if something like this patch made 
it into 4.1.

Thanks,
Chris

p.s. I had to move to 4.1.D2 to get this to work at all, 3.1.8 
returned "403 Forbidden" for forwards to WEB-INF

(Continue reading)


Gmane