You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wade Billings <wb...@lowermybills.com> on 2005/05/18 17:10:19 UTC
404 redirection question
I have the need to redirect visitors to my site to different error pages
depending on the type of element missing. For example, if the element
that is missing is an image file (e.g. *.jpg, *.gif), then I want to
present them with a custom 404 error page. If the missing element is an
entire page, then I want to present them with a completely different 404
error page.
I know that I can set Tomcat to catch the 404 errors and present a
custom page, but what I need to know is can I get as granular as I need
to get using the configuration, or do I have to put this in an jsp file
and solve it programmatically?
Thanks,
Q. Wade Billings
Manager, Operations / Sr. Unix Administrator
RHCE, CNA, CCNA, CNS
Operations and Technology Group
email: wbillings@lowermybills.com <ma...@lowermybills.com>
phone: (310) 998-6364
toll free: (800) 648-5049
fax: (310) 998-6999
cell: (661) 210-5593
snailmail: 2401 Colorado #200 Santa Monica , CA 90404
http: www.lowermybills.com <http://www.lowermybills.com/>
"Fall seven time. stand up eight."
- Japanese Proverb
"Never attribute to malice that which can be adequately
explained by stupidity."
- Hanlon's Razor
"I think we consider too much the good luck of the early bird, and not
enough the bad luck of the early worm."
- FDR
Re: Can a servlet receive its own request?
Posted by Dakota Jack <da...@gmail.com>.
Not something like "browsers" but browsers. I am not sure why you
find that difficult.
On 5/20/05, li yanjing <li...@gmail.com> wrote:
> sorry bothering you:)
> do you mean you are writing something like "browsers" in java?
> I really interested in that.I want a browser (can be without a GUI)
> that can browse the web with applet.I know it's easy in C/C++ or
> delphi ... but I found this is very hard in java...is that true?
> thanks
>
> 2005/5/19, Dakota Jack <da...@gmail.com>:
> > Those classes are "browsers" without a GUI. I do this sort of thing
> > all the time.
> --
> 李燕京
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
Re: Can a servlet receive its own request?
Posted by Dakota Jack <da...@gmail.com>.
Those classes are "browsers" without a GUI. I do this sort of thing
all the time.
On 5/18/05, Dakota Jack <da...@gmail.com> wrote:
> You might want to look at the COS message classes.
>
> On 5/18/05, Michael Mehrle <mi...@datasaur.com> wrote:
> > Simple question, but it's driving me nuts. I really don't want to get into
> > the whole web service business - all I need is for a servlet to be the
> > recipient of its own request. Or - in other words - can a servlet act like a
> > web browser - just without the GUI?
> >
> > Use case:
> >
> > - Servlet issues https request to an outside server (via
> > getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
> > - Outside server processes request and responds with POST response (also via
> > https).
> > - Servlet [somehow] is able to be the recipient of the response.
> > - Servlet parses the response and stores data to the database.
> >
> > Notes:
> >
> > - The servlet is not the default servlet on that tomcat instance.
> > - Everything happens via https and I expect the outside server will listen
> > on 443 and tomcat on 8443
> >
> > ANY suggestions would be very helpful - this seems to be a tricky one.
> >
> > TIA,
> >
> > Michael
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
> --
> "You can lead a horse to water but you cannot make it float on its back."
> ~Dakota Jack~
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by Dakota Jack <da...@gmail.com>.
You might want to look at the COS message classes.
On 5/18/05, Michael Mehrle <mi...@datasaur.com> wrote:
> Simple question, but it's driving me nuts. I really don't want to get into
> the whole web service business - all I need is for a servlet to be the
> recipient of its own request. Or - in other words - can a servlet act like a
> web browser - just without the GUI?
>
> Use case:
>
> - Servlet issues https request to an outside server (via
> getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
> - Outside server processes request and responds with POST response (also via
> https).
> - Servlet [somehow] is able to be the recipient of the response.
> - Servlet parses the response and stores data to the database.
>
> Notes:
>
> - The servlet is not the default servlet on that tomcat instance.
> - Everything happens via https and I expect the outside server will listen
> on 443 and tomcat on 8443
>
> ANY suggestions would be very helpful - this seems to be a tricky one.
>
> TIA,
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by Dakota Jack <da...@gmail.com>.
Requests from from a browser or any other suitable socket based
mechanism that sends requests. Servlets and servers don't send
requests, although you can have a client in a server that does send
requests. You could, I suppose, even build a request making mechanism
inside a servlet or as a field for a servlet. But, that does not mean
the servlet is making the request qua Servlet. Servlets handle
requests and return responses. Responses are not requests. Responses
tend to be HTML and requests are name value pairs and streams.
On 5/18/05, Michael Mehrle <mi...@datasaur.com> wrote:
> Simple question, but it's driving me nuts. I really don't want to get into
> the whole web service business - all I need is for a servlet to be the
> recipient of its own request. Or - in other words - can a servlet act like a
> web browser - just without the GUI?
>
> Use case:
>
> - Servlet issues https request to an outside server (via
> getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
> - Outside server processes request and responds with POST response (also via
> https).
> - Servlet [somehow] is able to be the recipient of the response.
> - Servlet parses the response and stores data to the database.
>
> Notes:
>
> - The servlet is not the default servlet on that tomcat instance.
> - Everything happens via https and I expect the outside server will listen
> on 443 and tomcat on 8443
>
> ANY suggestions would be very helpful - this seems to be a tricky one.
>
> TIA,
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by Michael Mehrle <mi...@datasaur.com>.
Yes, I'm now going the HttpClient route - and yes, I also realized that the
object to be launched doesn't have to be a servlet at all. I was just
anchored in thinking along those lines since I thought that the servlet
would be the one receiving its own response. Anyway, I think I'm on the
right track now.
Many thanks to everyone who replied to my post - every input was very
valuable.
Michael
----- Original Message -----
From: "Robert r. Sanders" <ro...@ipov.net>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, May 18, 2005 1:08 PM
Subject: Re: Can a servlet receive its own request?
> I've done something a little similar w/ the HTTPClient. What I ended up
> w/ was a Object that was run in the Servlet container but was not itself a
> servlet. Nit-picking. Anyway, you can do this, you just have to use
> other libraries (like the Commons HTTPClient).
>
> Michael Mehrle wrote:
>
>> Thanks for your elaborate reply - actually, someone else also suggested
>> to use commons HTTPClient. I might have over-explained all this - the
>> major difference is that the servlet is being launched by Quartz, not by
>> an outside HTTP request. Thus, it is the servlet that needs to be able to
>> receive the response to its own request, and it appears that HTTPClient
>> might enable the servlet to do this.
>>
>> Michael
>>
>>
>
> --
> Robert r. Sanders
> Chief Technologist
> iPOV
> (334) 821-5412
> www.ipov.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by "Robert r. Sanders" <ro...@ipov.net>.
I've done something a little similar w/ the HTTPClient. What I ended up
w/ was a Object that was run in the Servlet container but was not itself
a servlet. Nit-picking. Anyway, you can do this, you just have to use
other libraries (like the Commons HTTPClient).
Michael Mehrle wrote:
> Thanks for your elaborate reply - actually, someone else also
> suggested to use commons HTTPClient. I might have over-explained all
> this - the major difference is that the servlet is being launched by
> Quartz, not by an outside HTTP request. Thus, it is the servlet that
> needs to be able to receive the response to its own request, and it
> appears that HTTPClient might enable the servlet to do this.
>
> Michael
>
>
--
Robert r. Sanders
Chief Technologist
iPOV
(334) 821-5412
www.ipov.net
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by Michael Mehrle <mi...@datasaur.com>.
Thanks for your elaborate reply - actually, someone else also suggested to
use commons HTTPClient. I might have over-explained all this - the major
difference is that the servlet is being launched by Quartz, not by an
outside HTTP request. Thus, it is the servlet that needs to be able to
receive the response to its own request, and it appears that HTTPClient
might enable the servlet to do this.
Michael
----- Original Message -----
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Cc: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, May 18, 2005 10:05 AM
Subject: Re: Can a servlet receive its own request?
>
> If however, as I suspect might be the case, your servlet is going to
> actually be awaiting a reply from the outside server, then you should look
> at using Commons HTTPClient. I'm relatively sure it supports SSL
> connections, and then all your doing is making a remote request, awaiting
> the response and processing accordingly. It'd be just like using the
> standard URL object, but it's more robust than that.
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
You *probably* could do this... I'm not 100% sure.
What I *AM* sure about though is that this would be pretty ugly :)
I'm not sure what you mean by "Outside server processes request and
responds with POST response (also via https)." though...
Is the idea that the request to the outside server is to be asychronous,
or will your servlet be awaiting a reply? If the former, then you
probably can go with your approach and it won't be all that ugly... it's
essentially nothing more than another request coming in to the servlet,
same as always, your just going to process it differently... as long as
you get enough information back to be able to complete the "transaction",
it should work fine. Just treat the initial request to your servlet and
the response back from the outside server as two separate requests and you
should be fine.
If however, as I suspect might be the case, your servlet is going to
actually be awaiting a reply from the outside server, then you should look
at using Commons HTTPClient. I'm relatively sure it supports SSL
connections, and then all your doing is making a remote request, awaiting
the response and processing accordingly. It'd be just like using the
standard URL object, but it's more robust than that.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Wed, May 18, 2005 11:58 am, Michael Mehrle said:
> Simple question, but it's driving me nuts. I really don't want to get into
> the whole web service business - all I need is for a servlet to be the
> recipient of its own request. Or - in other words - can a servlet act like
> a
> web browser - just without the GUI?
>
> Use case:
>
> - Servlet issues https request to an outside server (via
> getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
> - Outside server processes request and responds with POST response (also
> via
> https).
> - Servlet [somehow] is able to be the recipient of the response.
> - Servlet parses the response and stores data to the database.
>
> Notes:
>
> - The servlet is not the default servlet on that tomcat instance.
> - Everything happens via https and I expect the outside server will listen
> on 443 and tomcat on 8443
>
> ANY suggestions would be very helpful - this seems to be a tricky one.
>
> TIA,
>
> Michael
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I don't think saying it's "silly" is really helpful, or even necessarily
accurate...
If the idea is that the request to the outside server is meant to to
asynchronous, i.e., maybe it feeds a queue or something, then it's a
reasonable model. It doesn't sound like that's what the OP meant, but if
it was, it would be reasonable.
Of course, even in that case the servlet is not "receiving its own
request", it is simply making a request, at which point it is done, and at
some future time receiving a request with the results.
I agree with you that Web Services need not be as complicated as some make
it out to be... no need to involve SOAP or XML-RPC or any other of the
numerous alphabet soup entries. I was doing "Web Services" seven years
ago, long before I heard the term. I suppose you could say that's not
"standards-compliant", which is one of the goals behind Web Services of
course... if everyone used the same mechanisms than theoretically it would
all be interoperable with no effort, and that's not the case if you
essentially cook up your own protocols, but since the reality is that even
following the standards you rarely get that right now, it's not such a
problem :)
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Wed, May 18, 2005 2:53 pm, Will Hartung said:
>> From: "Michael Mehrle" <mi...@datasaur.com>
>> Sent: Wednesday, May 18, 2005 8:58 AM
>
>
>> - Servlet issues https request to an outside server (via
>> getServletContext().getRequestDispatcher(https://www.someoutsideserver/)
>> )
>> - Outside server processes request and responds with POST response (also
> via
>> https).
>> - Servlet [somehow] is able to be the recipient of the response.
>> - Servlet parses the response and stores data to the database.
>
> Your problem is with the whole model.
>
> There is no reason why a Servlet can't send an HTTP(S) request to another
> server.
>
> But the server that you are making the request shouldn't be making an
> independent POST back to you, rather it should just send you the data you
> want back as the reply body. You then parse the reply and move on.
>
> IF you insist that the "reply" be in the manner of a POST from the other
> server (really really silly IMHO), then, simply, you need to make the
> request to the other server be the last thing your Servlet does. Then when
> the POST comes back, you pick up where you left off, tracking your state
> through a request parameter.
>
> So, your Servlet may start with a request like:
> http://otherserver.com/processData?mysession=123&stage=1
>
> Then the otherserver replies with a POST to:
> http://yourserver.com/yourServlet?mysession=123&stage=2
>
> You use the mysession information to maintain your state between requests.
> But the key is that your servlet ends each time, and Tomcat then restarts
> it
> when the POST comes back.
>
> It's still a silly idea. You don't need Webservices, SOAP, XML-RPC, etc to
> talk to another server via HTTP. You can easily stream serialized Java
> objects to each other if you want, use the simple Java Properties file
> format for your responses, etc. I think if you have control over both
> servers, "WEB RPC" can be very simple for a limited domain. If you don't
> have control over the other server, then you do what you have to do.
>
> I mean, seriously:
>
> public class AddNumberServlet extends HttpServlet {
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
> PrintWriter out = response.getWriter();
> String arg1 = request.getParameter("arg1");
> String arg2 = request.getParameter("arg2");
> int i1 = Integer.parseInt(arg1);
> int i2 = Integer.parseInt(arg2);
> int result = i1 + i2;
> out.println("answer=" + result);
> }
> }
>
> public class RequesterServlet extends HttpServlet {
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
> PrintWriter out = response.getWriter();
>
> URL reqURL = new
> URL("http://otherserver/AddNumberServlet?arg1=2&arg2=4);
> Properties result = new Properties();
> result.load(reqURL.openStream());
> String answer = result.get("answer");
> out.println("<HTML><BODY>When you add up 2 and 4 you get " +
> answer
> + "</BODY></HTML>");
> }
> }
>
> There. Instant "web service".
>
> Error checking and robustness are left as an exercise for the reader, but
> you can see that you don't need a 500 page book to get some data from
> another web server.
>
> Not to discount the XML-RPC and SOAPs, they have their place most
> certainly.
> No doubt XML-RPC started just like this and grew from there (and then into
> SOAP), but its just a simple example of how easy this can be when you have
> control over the whole shebang.
>
> Regards,
>
> Will Hartung
> (willh@msoft.com)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can a servlet receive its own request?
Posted by Will Hartung <wi...@msoft.com>.
> From: "Michael Mehrle" <mi...@datasaur.com>
> Sent: Wednesday, May 18, 2005 8:58 AM
> - Servlet issues https request to an outside server (via
> getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
> - Outside server processes request and responds with POST response (also
via
> https).
> - Servlet [somehow] is able to be the recipient of the response.
> - Servlet parses the response and stores data to the database.
Your problem is with the whole model.
There is no reason why a Servlet can't send an HTTP(S) request to another
server.
But the server that you are making the request shouldn't be making an
independent POST back to you, rather it should just send you the data you
want back as the reply body. You then parse the reply and move on.
IF you insist that the "reply" be in the manner of a POST from the other
server (really really silly IMHO), then, simply, you need to make the
request to the other server be the last thing your Servlet does. Then when
the POST comes back, you pick up where you left off, tracking your state
through a request parameter.
So, your Servlet may start with a request like:
http://otherserver.com/processData?mysession=123&stage=1
Then the otherserver replies with a POST to:
http://yourserver.com/yourServlet?mysession=123&stage=2
You use the mysession information to maintain your state between requests.
But the key is that your servlet ends each time, and Tomcat then restarts it
when the POST comes back.
It's still a silly idea. You don't need Webservices, SOAP, XML-RPC, etc to
talk to another server via HTTP. You can easily stream serialized Java
objects to each other if you want, use the simple Java Properties file
format for your responses, etc. I think if you have control over both
servers, "WEB RPC" can be very simple for a limited domain. If you don't
have control over the other server, then you do what you have to do.
I mean, seriously:
public class AddNumberServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
String arg1 = request.getParameter("arg1");
String arg2 = request.getParameter("arg2");
int i1 = Integer.parseInt(arg1);
int i2 = Integer.parseInt(arg2);
int result = i1 + i2;
out.println("answer=" + result);
}
}
public class RequesterServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
URL reqURL = new
URL("http://otherserver/AddNumberServlet?arg1=2&arg2=4);
Properties result = new Properties();
result.load(reqURL.openStream());
String answer = result.get("answer");
out.println("<HTML><BODY>When you add up 2 and 4 you get " + answer
+ "</BODY></HTML>");
}
}
There. Instant "web service".
Error checking and robustness are left as an exercise for the reader, but
you can see that you don't need a 500 page book to get some data from
another web server.
Not to discount the XML-RPC and SOAPs, they have their place most certainly.
No doubt XML-RPC started just like this and grew from there (and then into
SOAP), but its just a simple example of how easy this can be when you have
control over the whole shebang.
Regards,
Will Hartung
(willh@msoft.com)
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Can a servlet receive its own request?
Posted by Robert Harper <ro...@iat-cti.com>.
I don't think so. You will have to have something start the request.
Servlets are loaded by the container and are run in response to a request.
Once the servlet is running, there is no reason why it could not make an
http request for data from another server/servlet and parse the response.
Robert S. Harper
Senior Engineer
Information Access Technology, Inc.
1100 East 6600 South
Suite 300
Salt Lake City, Utah USA 84121-7411
(801)265-8800 Ext. 255
FAX (801)265-8880
This e-mail is intended only for the addressee and may contain confidential
and/or privileged information. Any review, retransmission, or action taken
upon this information by persons other than the intended recipient is
prohibited by law. If you received this communication in error, please
contact us immediately at 801-265-8800. Although this e-mail and any
attachments are believed to be free of any virus or other defect, it is the
responsibility of the recipient to ensure that anything received or opened
is virus free. No responsibility is accepted by IAT for any loss or damage
in the event that such a virus or defect exists.
-----Original Message-----
From: Michael Mehrle [mailto:michael@datasaur.com]
Sent: Wednesday, May 18, 2005 9:59 AM
To: Tomcat Users List
Subject: Can a servlet receive its own request?
Simple question, but it's driving me nuts. I really don't want to get into
the whole web service business - all I need is for a servlet to be the
recipient of its own request. Or - in other words - can a servlet act like a
web browser - just without the GUI?
Use case:
- Servlet issues https request to an outside server (via
getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
- Outside server processes request and responds with POST response (also via
https).
- Servlet [somehow] is able to be the recipient of the response.
- Servlet parses the response and stores data to the database.
Notes:
- The servlet is not the default servlet on that tomcat instance.
- Everything happens via https and I expect the outside server will listen
on 443 and tomcat on 8443
ANY suggestions would be very helpful - this seems to be a tricky one.
TIA,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Can a servlet receive its own request?
Posted by Michael Mehrle <mi...@datasaur.com>.
Simple question, but it's driving me nuts. I really don't want to get into
the whole web service business - all I need is for a servlet to be the
recipient of its own request. Or - in other words - can a servlet act like a
web browser - just without the GUI?
Use case:
- Servlet issues https request to an outside server (via
getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
- Outside server processes request and responds with POST response (also via
https).
- Servlet [somehow] is able to be the recipient of the response.
- Servlet parses the response and stores data to the database.
Notes:
- The servlet is not the default servlet on that tomcat instance.
- Everything happens via https and I expect the outside server will listen
on 443 and tomcat on 8443
ANY suggestions would be very helpful - this seems to be a tricky one.
TIA,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: CORRECTION: Can a servlet receive a response to its own request?
Posted by Atanu Neogi <At...@symantec.com>.
Make your servlet act like a java HTTPS client using the java.net.URL,
java.net.HttpURLConnection and javax.net.ssl.HttpsURLConnection classes.
Read from the response input stream (using java.io. classes) returned by
the connection. You will need to write your own hostname verifier and have
the target server certificate chain validated in your java certificate
store.
"Michael Mehrle" <mi...@datasaur.com>
05/18/2005 12:01 PM
Please respond to
"Tomcat Users List" <to...@jakarta.apache.org>
To
"Tomcat Users List" <to...@jakarta.apache.org>
cc
Subject
CORRECTION: Can a servlet receive a response to its own request?
Simple question, but it's driving me nuts. I really don't want to get into
the whole web service business - all I need is for a servlet to be the
recipient of its own request. Or - in other words - can a servlet act like
a
web browser - just without the GUI?
Use case:
- Servlet issues https request to an outside server (via
getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
- Outside server processes request and responds with POST response (also
via
https).
- Servlet [somehow] is able to be the recipient of the response.
- Servlet parses the response and stores data to the database.
Notes:
- The servlet is not the default servlet on that tomcat instance.
- Everything happens via https and I expect the outside server will listen
on 443 and tomcat on 8443
ANY suggestions would be very helpful - this seems to be a tricky one.
TIA,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
CORRECTION: Can a servlet receive a response to its own request?
Posted by Michael Mehrle <mi...@datasaur.com>.
Simple question, but it's driving me nuts. I really don't want to get into
the whole web service business - all I need is for a servlet to be the
recipient of its own request. Or - in other words - can a servlet act like a
web browser - just without the GUI?
Use case:
- Servlet issues https request to an outside server (via
getServletContext().getRequestDispatcher(https://www.someoutsideserver/) )
- Outside server processes request and responds with POST response (also via
https).
- Servlet [somehow] is able to be the recipient of the response.
- Servlet parses the response and stores data to the database.
Notes:
- The servlet is not the default servlet on that tomcat instance.
- Everything happens via https and I expect the outside server will listen
on 443 and tomcat on 8443
ANY suggestions would be very helpful - this seems to be a tricky one.
TIA,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: 404 redirection question
Posted by Fritz Schneider <Fr...@Peacham.HomeIP.net>.
David,
I'm differentiating between a link as in src= and a hyperlink as in href=.
For a link, the browser does indeed do another HTTP GET to retrieve it, but
if the result is a 404, the rest of the response is discarded and the image
is rendered as a small box with a red x in it.
On the other hand, if the image was the target of a hyperlink and it got a
404, the error page would be displayed (unless the IE "friendly" option were
selected). Example: http://peacham.homeip.net/notthere.jpg.
Fritz
-----Original Message-----
From: David Wall [mailto:d.wall@computer.org]
Sent: Wednesday, May 18, 2005 2:11 PM
To: Tomcat Users List
Subject: Re: 404 redirection question
Fritz,
Well, that's a hyperlink to the image, not embedded. In the case below,
the image is not embedded in the HTML but is simply a link to the image
that requires an HTTP(S) GET to retrieve. With a relative URL like you
used, it just constructs the complete URL by appending the current
page's URL to the front, so "images/xxx.jpg" becomes something like
"http(s)://www.host.com/app/images/xxx.jpg" assuming the HTML is located
at http(s)://www.host.com/app.
David
Fritz Schneider wrote:
>By having a page that is essentially:
><html><head/><body>
> <img src="images/xxx.jpg"/>
></body></html>
>
>
>
>Fritz Schneider wrote:
>
>
>>If you have hyperlinks
>>to images, as opposed to HTML pages with images embedded,
>>
>>
>>
>How would you embed images inside the HTML rather than using hyperlinks
>to the image?
>
>David
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: 404 redirection question
Posted by David Wall <d....@computer.org>.
Fritz,
Well, that's a hyperlink to the image, not embedded. In the case below,
the image is not embedded in the HTML but is simply a link to the image
that requires an HTTP(S) GET to retrieve. With a relative URL like you
used, it just constructs the complete URL by appending the current
page's URL to the front, so "images/xxx.jpg" becomes something like
"http(s)://www.host.com/app/images/xxx.jpg" assuming the HTML is located
at http(s)://www.host.com/app.
David
Fritz Schneider wrote:
>By having a page that is essentially:
><html><head/><body>
> <img src="images/xxx.jpg"/>
></body></html>
>
>
>
>Fritz Schneider wrote:
>
>
>>If you have hyperlinks
>>to images, as opposed to HTML pages with images embedded,
>>
>>
>>
>How would you embed images inside the HTML rather than using hyperlinks
>to the image?
>
>David
>
>
RE: 404 redirection question
Posted by Fritz Schneider <Fr...@Peacham.HomeIP.net>.
By having a page that is essentially:
<html><head/><body>
<img src="images/xxx.jpg"/>
</body></html>
-----Original Message-----
From: David Wall [mailto:d.wall@computer.org]
Sent: Wednesday, May 18, 2005 11:01 AM
To: Tomcat Users List
Subject: Re: 404 redirection question
Fritz Schneider wrote:
>If you have hyperlinks
>to images, as opposed to HTML pages with images embedded,
>
How would you embed images inside the HTML rather than using hyperlinks
to the image?
David
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: 404 redirection question
Posted by David Wall <d....@computer.org>.
Fritz Schneider wrote:
>If you have hyperlinks
>to images, as opposed to HTML pages with images embedded,
>
How would you embed images inside the HTML rather than using hyperlinks
to the image?
David
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: 404 redirection question
Posted by Fritz Schneider <Fr...@Peacham.HomeIP.net>.
Wade,
Browsers don't display the error page for missing GIF or JPEG elements in a
page, only when the entire requested URL gets a 404. If you have hyperlinks
to images, as opposed to HTML pages with images embedded, then what you are
looking for can be accomplished. You could create a JSP which does the
following to get the original URI:
// If this is an error page, get the original URI
String missingURI = (String) req.getAttribute(
"javax.servlet.forward.request_uri");
if (missingURI == null) missingURI =req.getRequestURI();
Fritz
-----Original Message-----
From: Wade Billings [mailto:wbillings@lowermybills.com]
Sent: Wednesday, May 18, 2005 8:10 AM
To: tomcat-user@jakarta.apache.org
Subject: ***SPAM*** 404 redirection question
I have the need to redirect visitors to my site to different error pages
depending on the type of element missing. For example, if the element
that is missing is an image file (e.g. *.jpg, *.gif), then I want to
present them with a custom 404 error page. If the missing element is an
entire page, then I want to present them with a completely different 404
error page.
I know that I can set Tomcat to catch the 404 errors and present a
custom page, but what I need to know is can I get as granular as I need
to get using the configuration, or do I have to put this in an jsp file
and solve it programmatically?
Thanks,
Q. Wade Billings
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org