SunQuest
 
       Java
  Home arrow Java arrow Page 7 - The JSP Files (part 3): Black Light An...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

The JSP Files (part 3): Black Light And White Rabbits
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2001-03-01

    Table of Contents:
  • The JSP Files (part 3): Black Light And White Rabbits
  • Doing More With Loops
  • For-gone Conclusion
  • The Sound Of Breaking Loops
  • Paying The Piper
  • You Say Seven, I Say 7
  • A Positive Response

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    The JSP Files (part 3): Black Light And White Rabbits - A Positive Response


    (Page 7 of 7 )

    Another interesting object, and one that comes in handy in the oddest places, is the Response object. As opposed to the Request object, which is used to retrieve information (come back next time for more on this), the Response object is typically used to send information to the browser; this information could include HTTP headers, redirection URLs, cookies and a variety of other items.

    Since the Response object is an "implicit" object (so called because you do not need to explicitly create an instance of the object when you want to use it), you can begin using it immediately in a JSP document. The following example demonstrates using it to turn off caching via the "Cache-Control" header.


    <% response.setHeader("Cache-Control","no-cache"); %>


    You can also use it to redirect the client to another URL.


    <% response.setHeader("Location", "error.html"); %gt;


    You can use the sendRedirect() method to accomplish something similar - remember to use an absolute URL here.


    <% response.sendRedirect("http://my.server.com/error.html"); %>


    You can set the MIME type of a document with the setContentType() method.


    <% response.setContentType("image/jpeg"); %>


    and even set a cookie with the addCookie() method - more on this as we progress through this series.

    That's about all we have time for. Next time, we'll be exploring the JSP Response object, used to process data from HTML forms...so you don't want to miss that one!

    Note: All examples in this article have been tested on Linux/i586 with Tomcat 3.2 and JServ 1.1. Examples are illustrative only, and are not meant for a production environment. YMMV!
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway