• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JspWriter variable "out " - giving trouble

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying close JspWriter variable out using out.close(); It works but the server (Orion) is throwing an unchecked exception

"Problem loading URL '/listvideos.jsp':javax.servlet.ServletException: The writer is closed."


Here is the jsp i am using...


<html>
<body>

obtaining arraylist...
<%@ page import="java.util.*, java.io.*" %>

<%

ArrayList list = (ArrayList)request.getAttribute("list"); %>
arraylist obtained...
<%


if(list!=null)
{
String temp;
for(int i=1;i<list.size();i++)
{
temp = (String)list.get(i);
out.println("<br>"+temp);
}
}
else
{out.println("Nothing in the list/ArrayList null"); }

out.println("<b> <a href=/addvideo.jsp >Add List</a> </b>");


out.close(); // IF I COMMENT THIS IT DOES NOT THROW THE EXCEPTION


%>

</body>

</html>



-------------------------------------------


Can anyone tell why is it doing so.


Thank you for your help.


Raghav
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should not close the ouputstream in a JSP file, because the container continues to use it to output the remaining tags and text.
For example, </body> will be transformed as </body> out.write("</body>");
If you close the stream, an exception will occur.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ice_storm,
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
 
Raghav K Aggarwala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Satou
 
Sheriff
Posts: 67746
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
"kamal",

Please actually read Ben's request and change your display name accordingly.

bear
JavaRanch sheriff
 
Raghav K Aggarwala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"kamal",

Please actually read Ben's request and change your display name accordingly.

bear
JavaRanch sheriff
------------------------------------------------------------------

Attn: Bear Bibeault-sheriff


Display name has been changed to my actual name.

What else do you want me to do?


Kamal
 
Bear Bibeault
Sheriff
Posts: 67746
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
Repeating what Ben said:

your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.



Please change your display name accordingly prior to you next post in order to avoid the disabling of your account.
 
Bear Bibeault
Sheriff
Posts: 67746
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
And "A" is not an acceptable last name. Your first name can be an initial, but not the last.
[ July 08, 2006: Message edited by: Bear Bibeault ]
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic