Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:11:05+00:00 2026-05-23T03:11:05+00:00

I am trying to create a request log for my web app. I am

  • 0

I am trying to create a request log for my web app. I am using Spring 3.
0.

I implemented a class extending HandlerInterceptorAdapter and used the preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) to intercept the request.

In the method i want to be able to log the request body (my parameters are objects in XML that are written directly to the request body), and for that i use request.getReader();

The problem is – later on I will get an IllegalStateException when the spring controller tries to read the request.

Is there a way to do what I intend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:11:06+00:00Added an answer on May 23, 2026 at 3:11 am

    You can do this with a filter. The request parameters are easy to handle.
    However dealing with the request body will be much more difficult
    and will require wrapping the servlet request see: HttpServletRequest.

    You will need to look how big the incoming request is and decide whether you want to store the request body as a tmp file or string.

    You will need to override ServetRequest.getInputStream() with your file or saved string that used for logging.

    If the request body is huge I recommend putting the input stream into a buffered input stream and then reading the start of the body.

    public class LogRequest extends HttpServletRequestWrapper {
    
        public LogRequest(HttpServletRequest request) {
            super(request);
        }
    
        @Override
        public ServletInputStream getInputStream() throws IOException {
            //read from tmp file or string.
        }
    
        @Override
        public BufferedReader getReader() throws IOException {
            //read from tmp file or string
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a web app that is querying my oracle database
I am trying to login to my web app using HttpWebRequest but I keep
I am a newbie trying to create a sample web application using; MySQL Java
I am trying to create a light weight web interface using embedded jetty to
I'm trying to create a script to log into a JSP website using LWP
I am trying to create a post request to the tumblr api. Shown below
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create a facebook app just to learn and coming across a strange
Trying to create a macro which can be used for print debug messages when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.