Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JspWriter variable "out " - giving trouble  RSS feed

 
Raghav K Aggarwala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Satou
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!