File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Response code from GET request to jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Response code from GET request to jsp page" Watch "Response code from GET request to jsp page" New topic

Response code from GET request to jsp page

Dave Springer

Joined: Jun 11, 2012
Posts: 3
Hi all,

I am a beginner when it comes to JSP and SimpleFormController programming.

I am receiving a GET request from a third party company, who are expecting a 200 response code back.

My JSP page is basically blank, but when a GET request comes in, it is automatically submitted to the onSubmit method in my controller, and a http response code of 201 is sent back.

How can I send a 200 response code back, instead of 201??

Thanks very much,

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60800

201 is an odd status to be returning. it means "created" rather than "success".

Is your code doing something to return the 201, or is it the Spring framework doing it?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Springer

Joined: Jun 11, 2012
Posts: 3
Hi Bear,

I don't think so. It is bypassing any code I have in my jsp (a line of code calling a function to send me an email), and going directly to my onSubmit method.

I therefore think it is something in the Spring Framework.


Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Well, first off. SimpleFormController is an old way of doing Spring MVC. Unless this is a legacy application, I recommend learning the latest Spring MVC which uses Annotations and your Controller classes are POJOs, no extending or implementing any Spring classes.

You can make your Controller return a status code in Spring @MVC by annotating your POJO controller method with @ResponseStatus(HttpStatus.OK)


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dave Springer

Joined: Jun 11, 2012
Posts: 3
Hi Mark,

Thanks for your reply. Unfortunately I am trying to integrate this with an older system, already using the SimpleFormController.

Could the 201 response be due to a new form being created? I have commented out the successView and formView in order to avoid this, but still the same error.

Do you know why my jsp page is being bypassed completely when there is a GET request to it, and going straight to my onSubmit method?


It is sorta covered in the JavaRanch Style Guide.
subject: Response code from GET request to jsp page
Similar Threads
Calling servlet on page load
Invoke JSP from within backend code?
Bean question
Displaying SOAP response using JSP