• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show output on original JSP page?

 
Cezanne Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem that i have a servlet and a jsp page. This jsp page sends the parameters to servlet which then generates a graph. But the problem is that the graph is being displayed in the servlet and i have to go back to the jsp page to select other values. What i want is that when user selects a value and click on the button, then instead of displaying the chart in servlet, it should display in the jsp page. How can i achieve such functionality?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet shouldn't be generating the output. After it does the computations, it should forward to a JSP to create the display.

See this article for details on how to properly structure web applications.
 
Cezanne Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Your servlet shouldn't be generating the output. After it does the computations, it should forward to a JSP to create the display.

See this article for details on how to properly structure web applications.


But the problem is that the servlet is displaying the chart after taking values from a jsp, and i want to include that chart (whether as an image or the servlet is passed to another jsp, and that jsp is included in the previous jsp). How i am gonna achieve this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why fool around with included JSPs?

Just write the JSP so that it can display the chart if it exists, but skip it if it doesn't. That way all the original controls are "repeated" on each view. Your servlet will simply forward to the same JSP.

(Although if you read the article, you might want to use the PRG pattern to avoid refresh problems.)
 
Cezanne Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, i have read about request dispatcher. Will it be feasible in this situation? If so, how'll we achieve such functionality?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know what you are asking. Give it a try and come back with specific questions.
 
J Srinivas rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If chart is being displayed in servlet and you want to include that in your jsp
simply use following code in your jsp page
<img href="your servlet url" widht="500" height="500">
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic