Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the jsp content from a struts action in OC4J

 
menon sandeep
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts 1.2 with OC4j container. For printing purpose i need to get the content of a jsp file generated from a struts action in a normal java class. For that i am passing the request and response object to the generate method in the java class. I hope that by overriding the getWriter() method we can achieve the functionality.


But although the action is processed, the content is always empty. Please advice
 
menon sandeep
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any One please
 
Joe Ess
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Be Patient. We are all volunteers here, answering questions in our spare time.
 
menon sandeep
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to get the content using HTTPClient

But still no luck as the temp variable only contains the html content for the login page although i am setting the state
 
Joe Ess
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to do this within an Action or a stand-alone Java program? If you are on the server side, HttpServletResponseWrapper makes sense. If you are on the client side, HttpClient makes sense.
 
menon sandeep
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks for the reply. I am trying to do this from the server side. So i think HttpServletResponseWrapper is the correct choice
I have gone through the suggestions in the below thread which more or less matches with my requirement
http://stackoverflow.com/questions/1963158/capture-generated-dynamic-content-at-server-side
Is there any other way we can achieve the objective?
 
menon sandeep
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the filter pattern whenever a servlet with a particular url pattern is accessed, it can process the content of the resultant jsp.
Is there any other way we can invoke a servlet from a struts 1 action without using the requestDispatcher object as it includes the wrapped response also with the final result?
 
Joe Ess
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've what you are trying to do with HttpServletResponseWrapper, though the example I have handy has a bunch of other requirements that obfuscate the solution. One difference I see is that I used RequestDispatcher.forward rather than include.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic