• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Spring MVC 4.1 RedirectAttributes is not working properly

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to the Spring MVC. I am using the Spring release 4.1.6 and deployed my two web applications A and B on tomcat 7 for the development environment. But in the actual production environment the application A will be deployed on weblogic and application B will be deployed on websphere. Below is the scenario occuring on the development environment.

Application A has testrequest.jsp page available in the test directory.Below is the code for the jsp page.



If we look at the action attribute of the form carefully , when the form submits the request must go to the TestController.java. TestController.java has methods to handler the GET(load the page) and POST(submit the page) request.Below is the code for the same.



Below is the RequestDetails(Model) object available in the application B.



When I am executing the URL to display the jsp page http://localhost:8080/b/createtestrequest.test (to set the empty model object in the request) then the controller method**(requestForm(HttpServletResponse httpServletResponse,HttpServletRequest httpServletRequest,RedirectAttributes redirectAttrs)**) to handle get request does gets invoked with the below output but it does redirect to the page testrequest.jsp available in the test directory of the Application A. But it is giving the below error on the browser

output on the tomcat console

*********** Get Request reaches the TestController *******************

Below is the error coming on the browser



I somehow need the Userdefined object "testobj"available in my request object to load the test.jsp page with the available values in the object but it seems to be not working as expected.I have two questions

1.Is it possible to make the user defined object available using the RedirectAttribute class in the case of redirecting the request using some other workaround?
2.In future I will be validating the jsp form using the Spring Validation support in that case I need to made available org.springframework.validation.BindingResult object to my jsp page in the application A so will that be possible as well?

In simpler terms let me explain the problem. I have jsp page in application A , when I execute the url to load the page, the controller is available on application B needs to be invoked.The controller must set the model object and redirect to the jsp page on the application A.
 
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is Application B like a service only? And Application A is your web layer?

I mean, If Application B is a service layer, it should not deal with 'model's, but rather service classes. The controller in the Application should handle models.

Not sure if I understand your design correctly. Maybe explain your design why there are 2 applications, etc.?
 
jinesh parikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Thanks John Cruz for your prompt reply.

Application A contains JSP pages only and nothing else. Application B has controllers, Models and Service layer and persistence layer.

Any GET and POST request submitted by the JSP page of Application A must go to the controllers created in the Application B. The controllers in the web application B must handle the request , if all the validations are correct then they will call the service layer in the application B and store the data in the oracle database. But If there are any validation errors then they must return the error messages back to application A and display the jsp page.

Originally, I have tried to mimic the production environment scenario over here. In case of the production environment we have Application A needs to be deployed on the Weblogic and Application B needs to be deployed on the Websphere server. But for some reason, we don't want the JSP pages to be placed on the websphere sever's box(I don't now the reason).

Please do let me know If I failed to clear your doubts. One more follow up question is that Is it a good design having the JSP page on one Application and the controllers and models needed to handle the request of this JSP page is been placed in the different application?
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Honestly, to my knowledge, this is a very bad idea.

You are able to get away with it in Tomcat, because they are together.

Some designs put a web server, in front of application servers. The customer talks to the the web server only. There is no jsp, controllers, etc. in the web server. Everything is on the application server. I wonder why you are not allowed to have the jsp in the websphere server. You deserve to know before you can give them a good solution. You can ask them, whoever dictates you not to do so.
 
jinesh parikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@John Cruz Thanks for the prompt reply.

Actually, we have some constraints with the third party server hence so we are not allowed to place jsp there.

Anyways, If we are keeping the same design as dictated in my question , Is there any possible way I can make below things work.

1.Is it possible to make the user defined object available using the RedirectAttribute class in the case of redirecting the request using some other workaround?
2.In future I will be validating the jsp form using the Spring Validation support in that case I need to made available org.springframework.validation.BindingResult object to my jsp page in the application A so will that be possible as well?
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still think you have to make a clear separation.

I assume the Application B controllers are exposed like of a REST-type of interface.

I would still put all my concerns in the Application A, like controllers, and call Application B controllers at the appropriate time (from controllers in Application A, not direct from JSP in Application A), e.g. after doing validation etc. (all in Application A).

I really dont know anymore beyond this.
 
It will give me the powers of the gods. Not bad for a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic