public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String targetId = request.getParameter("id");
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().println("<test>" + "response from doPost()" + "</test>");
}
Correlation does not prove causality.
http://plainoldjavaobject.blogspot.in
Lalit Mehra wrote:Hi,
Please post a detailed exception trace.
Correlation does not prove causality.
Roger F. Gay wrote:I'd give you more if I had more. Let me know if you think there's a way to get more.
Author of ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- OCPJP Online Training -- Twitter -- How to Ask a Question
Devaka Cooray wrote:OK, I am not with enough resources to give this a try, but I suspect that this might be because you closed your OutputStreamWriter before fetching out the response.
Despite the fact that it is technically possible to 'call' a servlet from another servlet though sockers, I don't understand why would someone really do that, given that inter-socket communication is not a light-weight process. Are you probably attempting to communicate with two servlets that are in two different web applications?
If sharing some business functionalities between two servlets in a single web application is all what you wanted, why don't you simply place that centric logic in a method accessible to both servlets?
Roger F. Gay wrote:I'd give you more if I had more. Let me know if you think there's a way to get more.
You should be able to see your stack trace in your container's log file(s). If you are using Tomcat, there are in 'logs' directory.
Correlation does not prove causality.
java.net.SocketTimeoutException: Read timed out
Ayan mallick wrote:
java.net.SocketTimeoutException: Read timed out
I have tested for the code you have posted and it's working fine. so the only reason is probably in real scenario you are going to read large chuck of data which is taking time. please check once increasing time limit of this line
Thanks
Ayan
Correlation does not prove causality.
Roger F. Gay wrote:I'm using an http call in order to getremoteaddr().
Author of ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- OCPJP Online Training -- Twitter -- How to Ask a Question
Devaka Cooray wrote:
Roger F. Gay wrote:I'm using an http call in order to getremoteaddr().
I am not sure I correctly understand what you mean. Are these two servlets belonging to the same web application, or are they in two different VMs? What are you trying to get from getRemoteAddr()? If these two servlets are deployed on same host, whatever you get with a getRemoteAddr() will be equivalent to 127.0.0.1, i.e. the localhost because the client, which itself is a servlet, is running on the same host. Do you probably want a way to get the IP address of your server or something?
Correlation does not prove causality.
Roger F. Gay wrote:Yes, I want the public IP address, and I'm getting it using request.getRemoteAddr() even though both servlets are in the same application ...
Author of ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- OCPJP Online Training -- Twitter -- How to Ask a Question
Devaka Cooray wrote:
Roger F. Gay wrote:Yes, I want the public IP address, and I'm getting it using request.getRemoteAddr() even though both servlets are in the same application ...
If getting server IP is all what you want, you can get it through request.getLocalAddr() - there is no need to have a socket approach just to get the local IP of any potential network system I can think of. A socket-based approach may technically work here, but that definitely is a really bad practice and you are going to end up with danged performance issues when you make your application go on production. As Bear and I explained, having a socket connection between two servlets in a single web application is an entirely pointless idea, unless you want to see how worse a bad practice can be.
Correlation does not prove causality.
Bear Bibeault wrote:You still haven't answered my question. I get the feeling that you are building this:
![]()
When all you really need is to walk to the window and open it.
So what is it that you are actually trying to accomplish? Now how, but what.
Correlation does not prove causality.
Bear Bibeault wrote:SO what does that have to do with Servlet to Servlet communications?
Correlation does not prove causality.
Correlation does not prove causality.
Often the most important part of the news is what they didn't tell.
Correlation does not prove causality.
Roger F. Gay wrote:Would be nice to get a solution working though. The alternative is to call an external site. There are a few around that will return your IP address.
Often the most important part of the news is what they didn't tell.
Correlation does not prove causality.
Often the most important part of the news is what they didn't tell.
Correlation does not prove causality.
You didn't tell me he was so big. Unlike this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|