Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IE shows "This program cannot display the webpage" when I run my servlet

 
tuntony wei
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys:

I just start to use Servlet and now I met a problem when I tried to call a method in my servlet. Could anybody give me some suggestions to solve this problem?

Here is what I am doing:

1. I have a form, <form name="inputform" action="PerformWebTestServlet" onsubmit="loadingPage()" method="post">
2. In the doPost(reqs, reps) method of the PerformWebActionServlet, I new another class and try to invoke a method of this class to get some result. Please see:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession(true);
DataBean dataBean = (DataBean) session.getAttribute("dataBean");
... ...
SingleTestWebImpl runner= new SingleTestWebImpl();

try {
runner.doWork(dataBean .getMppigName, dataBean.getVerifyxmlName, dataBean.getTestcasename(), "false", dataBean.getLogfile());

} catch (InvalidMappingException e) { }

RequestDispatcher requestDispatcher = request.getRequestDispatcher("SemanticTestResult.jsp");
requestDispatcher.forward(request, response);
}

3. My problem is the runner.doWork(). This method involves some database querying work. if it can be finished in a short time, everything is fine. It can go to the SemanticTestResult.jsp and shows the result. However, if the runner.doWork() needs a little longer time, for example 15+ seconds. The IE will show "This program cannot display the webpage" Please see the attached pic. And also I found the method runner.doWork() is sitll able to successfully finished in the console and at this time, if you input the right url of SemanticTestResult.jsp at IE, I am still able to see the right result.

I feel this is probably a connection timeout problem. But I just do not know how to solve this problem. I mean when the servlet runs the longer runner.doWork(), how can I let IE connection alway alive and wait for result?

Thank you so much.
U.jpg
[Thumbnail for U.jpg]
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
making your users wait that long is a bad idea anyway. If you want my opinion, I'd start your doWork method in another thread and get the results when the method's finished through an AJAX request.


Also, UseCodeTags.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further suggestion - turn off the IE "friendly HTTP error messages" so you can see real error codes.

Tools -> Internet Options -> Advanced tab -> Browsing group

Bill
 
tuntony wei
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys:

Thank you very much for suggestions. It seems starting a thread from servlet is the only way to do this.

Here I have a following question. I started a new thread from my servlet and the servlet redirected to a jsp, the new thread finished its job, Now I want the jsp can display the result obtained from the thread. So, before my servlet redirect to the JSP, I put the thread's reference into session, and then I refresh the jsp automatically again and again. But I just found I can not get the result is still null after the thread finished.

Can I do this? How can I keep refesh a jsp to watch a session or a javabean?

Thank you again
 
Jeff Ishar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi tuntony,
If your database query takes more than 15 seconds then you need to check your method seriously where db interactions is happening i.e. doWork. Make sure you close the connections, catch exceptions and close the result set and other stuff (If using JDBC). Please post that method here.
In my web application even the biggest operation takes about 10 seconds, 15+ sec is far too much.

Cheers
 
tuntony wei
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you so much. The database function is from other part of my team. Unfortunitely, I can not change it. Now, I just changed my code to throw a thread. The thread is a worker to invoke the db func. Then at same time, my servlet/jsp is keeping refresh to monitor if the thread finished.

I saw lots of people doing in this way. So ... But I still feel confused because lots of people on web says "do not thrown thread in servlet", but this seems the only way to solve long time process. And servlet 3.0 supports asynchrozed task.... I am new to Servle/Jsp. There are really lots of things for me to learn.

Still, thank you so much for the advice. In future, I will do check the db func to make faster.


Jeff Ishar wrote:Hi tuntony,
If your database query takes more than 15 seconds then you need to check your method seriously where db interactions is happening i.e. doWork. Make sure you close the connections, catch exceptions and close the result set and other stuff (If using JDBC). Please post that method here.
In my web application even the biggest operation takes about 10 seconds, 15+ sec is far too much.

Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic