• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

doGet executes 2 times

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 22
IntelliJ IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Saloon Keeper
Posts: 24293
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic