Results 1 to 3 of 3

Thread: Can i 'intercept' output?

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    4

    Question Can i 'intercept' output?

    Hi,

    in a existing spring mvc web project i want to check for some condition and then output generated html code instead of what would be shown normally, how is this possible?

    Pretty much what in PHP would be:

    Code:
    if ( $condition ) {
      die( '<html><body>denied</body></html>' );
    }
    i do have the ServletResponse on this point, so i was going for:

    Code:
    PrintWriter pw = response.getWriter();
    pw.write( "Test" );
    But this does not seem to work (plus i don't know how to prevent the rest of the view to be displayed)

    Any ideas?

  2. #2
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default

    I think a cleaner approach would be to put this condition logic within your controller and use a different "view" based upon the condition. This way you are not putting logic within your jsp.

  3. #3
    Join Date
    Apr 2008
    Location
    Seville, Spain
    Posts
    132

    Default

    You may use a HandlerInterceptor as shown in http://static.springsource.org/sprin...ng-interceptor

    Cheers
    Jose Luis Martin
    Freelance Senior Consultant
    JDAL - Java Database Application Library

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •