aspose file tools*
The moose likes Servlets and the fly likes Show output on original JSP page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Show output on original JSP page?" Watch "Show output on original JSP page?" New topic
Author

Show output on original JSP page?

Cezanne Khan
Greenhorn

Joined: Aug 20, 2012
Posts: 18
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

Joined: Jan 10, 2002
Posts: 60053
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Cezanne Khan
Greenhorn

Joined: Aug 20, 2012
Posts: 18
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

Joined: Jan 10, 2002
Posts: 60053
    
  65

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

Joined: Aug 20, 2012
Posts: 18
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

Joined: Jan 10, 2002
Posts: 60053
    
  65

I do not know what you are asking. Give it a try and come back with specific questions.
J Srinivas rao
Greenhorn

Joined: Feb 25, 2011
Posts: 9
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">
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Show output on original JSP page?
 
Similar Threads
Tool tip is not coming when we displayed a graph in JSP
Run servlet and applet only limited times on IE?
session mangement problem
Servlet to Applet
applet not loaded