Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doGet executes 2 times  RSS feed

 
Joris Claus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm quit a Newbie in Servlets, so gimme some slack please.

I created a new servlet to download a pdf-file from a unix-server and display it in an iFrame. The servlet gets called, downloads the pdf, throws away the session parameters and then... starts over again. The session parameters aren't there anymore and the servlet returns an error. The strangest thing is, in our development environment the thing works. In our testing environment, it executes twice, so I'm thinking of a difference in the configuration, but I haven't got a clue where to look anymore...

web.xml


page-jsp


DownloadIframeContent.java


This is what I see in my logging
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like it is actually getting two requests, so see if you can determine what might cause that.
What differences are there between dev and test?

If you use the browser dev tools to monitor the browser requests, does it actually send two requests?
How about the server request logs?
Does it do that in Dev?
If it isn't the browser, then what else might do it? Clustering setup? Load balancing? Anything like that set up in the test environment that isn't in dev?
 
Joris Claus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem 's solved! :-)

During the transfer of the pdf-file, I wrote twice into the response-outputstream.

outputStream.write(fileContent,0,fileContent.length);
outputStream.write(fileContent,0,fileContent.length);

The odd thing is, in the development area this caused the pdf sometimes to appear a second time in the next refreshed frame, once you clicked away from the iFrame-page, in our testing-environment, it caused the doGet to be executed twice...

Thanks for the help provided. In the end, it was some stupid coding-error, but glad a colleague found it.
 
Vitaliy Gaydarenko
Greenhorn
Posts: 22
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh... doGet(), doPost() it is deprecated. This technology use in 2000-2002 years.
Start learning something new..., as Spring MVS - modern and not,so hard in learning .
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vitaliy Gaydarenko wrote:Oh... doGet(), doPost() it is deprecated. This technology use in 2000-2002 years.
Start learning something new..., as Spring MVS - modern and not,so hard in learning .


Whether it's Spring MVC (sic), Struts, JSF, whatever, the foundations of all the J2EE/JEE web applications are servlets. Even JSPs compile down into servlets.

So if you want to use a "modern framework" without the faintest clue of how things work, by all means, skip understanding servlets and their methods.

However, if you're using JSF and you come to the JSF forum for assistance in getting a JSF webapp to output a PDF, I'm going to advise you to NOT use JSF and use a raw servlet (or JSP) for that part of the app, since JSF is an HTML MVC framework and not a document-producing framework.

Just because something's been around a while doesn't mean it's useless.
 
Vitaliy Gaydarenko
Greenhorn
Posts: 22
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Just because something's been around a while doesn't mean it's useless.

Yes, you must understand how it work.
I said, that you should not use this in real project.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nonsense. Servlets are as relevant today as they ever were. As Tim already pointed out, even if you are using frameworks, servlets still have their place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!