aspose file tools*
The moose likes Servlets and the fly likes JSP Vs Servlet - A peculiar scenario Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP Vs Servlet - A peculiar scenario" Watch "JSP Vs Servlet - A peculiar scenario" New topic
Author

JSP Vs Servlet - A peculiar scenario

Gaurav Kushwaha
Greenhorn

Joined: May 20, 2009
Posts: 19
Hi,
I have a faced a scenario, wherein I am not able to know the reason for it.
While trying to display an html page (kept in my local directory), I have created 2 web projects. One with only a jsp and written file I/O code to get the file and writing in the ServletOutputStream. But it didn't work. It gave me IlleagalStateException, saying getOutputStream already called.

However, the other project wherein I had a servlet, with same code. It worked fine.

I am not understanding the reason.


Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12822
    
    5
It gave me IlleagalStateException, saying getOutputStream already called.


Explains the reason - in a JSP, the output stream is automatically created by the code created by the JSP compiler so that you will have the automatic variable "out"

Examine the created servlet code to see all the work that JSP does automatically to set up out and other variables.

Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61608
    
  67

Are you putting Java code into your JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gaurav Kushwaha
Greenhorn

Joined: May 20, 2009
Posts: 19
No Bear, I am maintaining a decade long code which was written in jsp
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61608
    
  67

My condolences!
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Gaurav Kushwaha wrote:I am maintaining a decade long code which was written in jsp

so, those all the day you were getting the exception?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Vs Servlet - A peculiar scenario