Can Spring Web Flow Work in Non Spring MVC application? [closed] - spring

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on evaluating Spring Web Flow for handling conversational flows in the web application that is currently used. Currently, the web application that we are using using is a custom company made MVC framework that was developed 10+ years back when there was no Spring MVC or Struts etc. There is a ControllerServlet in the application which is currently doing the work of managing the requests, similar to DispatcherServlet of Spring MVC.
Now, we want to take advantage of the Spring Web Flow features and renew the application and ease the developers life. I would like to know from all you people out here who had similar experiences in the past of migrating legacy MVC application to Spring Web Flow.
Please suggest the configurations and / or changes which I should be looking at to take this into right direction.
Some of the questions which come naturally to my mind are:
Configuration changes to web.xml? or adding a spring related xml file?
Any changes that we need to make to the JSP's? I am assuming Spring Web Flow will require me to make changes in the JSP's. What do you guys feel?
How could we get rid of the ControllerServlet? or better yet ask the ControllerServlet to refer to Spring Web-Flow for all the requests?
If Spring Web Flow is replacing the ControllerServlet, what happens to all the code that is written in it? what equivalenet of Spring Web Flow do we need to write?
Thanks,
Yogendra

Why replace, you can perfectly use Spring Web Flow (and/or Spring MVC for that matter) alongside your own MVC framework. You only have to be careful when you are crossing boundaries between the 2.
What we did in such a scenario was introduce a DispatcherServlet for only handling the Spring Web Flow request and everything else was handled as before. So you basically have 2 servlets instead of 1.
Another solution would/could be to replace your own servlet with a DispatcherServlet and let all requests for the old part of the application delegate to your own ControllerServlet, for this you could use the ServletWrappingController of Spring MVC.
Benefit of the last approach is that you could create a HandlerInterceptor which could move some stuff around from your own MVC framework to SWF and vice-versa.
In each and every car you would need to change the pages that use Spring Web Flow to use the Spring tag libraries so that form can be properly handled, for pages that aren't used/served by Spring Web Flow everything can remain the same.

Related

When do we use Spring Boot templates? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
When do we use spring boot templates?
I understand that they're used with templating engines such as thymeleaf but I'm confused as to when to use them.
For example;
Is this merely for testing purposes and once published we're done and ignore the templates and the web designer / developer has to implement the service or is this something that's part of our application and can't be removed?
Because, to me, it wouldn't make sense for us to pile all of our website html/css/etc inside the same package / project folder that we use to deal with server side stuff?
There is no such thing as Spring Boot templates. Spring Boot integrates with different templating engines where Thymeleaf is one of the (more popular) possible choices.
With Thymeleaf you render the HTML on the server side using a combination of Java code (in the Spring MVC #Controller classes) and the HTML based Thymeleaf templates. The rendered HTML is then returned to the browser where it is rendered into what the user sees.
As such, it makes perfectly sense to package it as part of the Spring Boot application, as it is what runs on the server.
No, it's certainly not just for testing purposes. If you use them, you will use them as part of the application in production too. It is part of your application.
Because, to me, it wouldn't make sense for us to pile all of our website html/css/etc inside the same package / project folder that we use to deal with server side stuff?
why would you use same folder for each? Usually you split them into different folders, even when using Thymeleaf or some other template engine.
If you are actually asking about using javascript frameworks to create your frontend and combining that to a spring app, maven-frontend-plugin is often used.

End-to-end flow for Spring Applications

I am a Spring newbie and I would like to have a proper understanding of how a Spring based web application works end-to-end. Good'ol CGI, PHP, servlets and JSP have been around long enough that I believe I have a decent understanding of the end-to-flow for those technologies. I am seeking a similar clarity for Spring.
Specifically my question is whether Spring also follows a "container" architecture, similar to servlets (i.e. whether there is an execution environment within the context of the web server within which the business logic runs) or whether there is a different flow altogether.
There is undoubtedly literature out there but I find that it focuses mainly on POJOs, metadata, configuration files, annotations etc.
Based on the comment from #JB Nizet, I did some search on the Dispatcher Servlet and I found the following graphic which seems to very clearly show the end-to-end flow for Spring applications:

How to get values on server side in Spring ROO?

I am having a question regarding Spring ROO. Although this is not a good question to ask still as i am facing some issue.
I have created Spring ROO application using below link in Eclipse
http://docs.spring.io/spring-roo/reference/html/beginning.html
After putting some efforts i was able to see the application output as desired then a doubt came to mind that how i will print value from browser to Controller i.e. client to server side (System.out.println("")).
I have tried many solution but nothing seems to be working. So can some one tell me how will i do it.
Just to summarize the thing i want value from textfield etc in my .java file using above Spring ROO project.
Spring Roo just creates a Spring Web MVC application.
In your question I found that you need some architectural concepts about Spring Web MVC and Web applications that you must know to start developing application.
Try to read some tutorials and post (this looks good) before start to develop your application.
Good luck!
Chema.

Spring vs Java EE 7 [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Now I am reading "Begining Java EE 7". And I was wondered that Java EE 7 is a good stack of technologies, it includes CDI, bean validation, JSF for web tier and other specifications.
So I got a question:
Why should I study Spring framework if Java EE 7 exists and covers all capabilities which Spring implements?
I will share little bit of what I know about using Spring. You are right by saying that Java EE 7 has all the technologies to help solve the problems.
Well Spring just enhances these capabilities and makes life more easier for a developer.
As an example when you use Spring MVC framework you can use Spring UI tags to create your JSP and those tags in turn can help you map the values directly to your controller. By controller I mean the Java class which is invoked when you do form submit. It also helps you to validate the form data.
This can be achieved using the Servlet technology also but Spring lets you focus on business logic and it takes care of these.
In my experience as a developer its good to know and understand Java EE 7 but frameworks like Spring utilize some of the best practices and patterns to make life easier for developers.
Would like to hear the opinions from others as well.
Hope this helps.
I think that one simply should know both of them. Spring has a huge community and is used widely, but Java EE is now going forward too, using many technologies that are in Spring in its latest versions.
However, it is incorrect to say that Java EE covers all the fields that Spring does. In my opinion Spring still has something that could make the difference, if you work in particular domains, such as mobile (Spring mobile), social (Spring social), navigation flows management (Spring Webflow) and others.

Java EE architecture and pattern [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm developing a web application for a university project and it has been told to us to use Java EE and to provide documentation. I'm having trouble understanding how to fit the MVC pattern in the multi-tier architecture and how to describe them, since I've found articles on the internet saying different things.
From what I read (expecially about BluePrints at sun.java.com), I should use 4 tiers (client, web, business and data) and the business logic is divided between web and business tiers, isn't it? Then I can use the MVC pattern to organize these two layers:
Model = entity beans
View = JSPs
Control = servlets and session beans
Am I right?
There are a couple of approaches to MVC in Java EE.
The somewhat older approach (but depending on the context still valid) uses JSP for the view and Servlets for the controller. It's often debated what the model exactly is, but it's typically taken to be Services (represented by e.g. EJB session beans) that return domain entities (represented by e.g. JPA Entities).
In modern versions of Java EE, there's a default MVC framework called JSF. Following this framework, Facelets is used for the view and the controller is given (you don't need to implement it).
There's an in-between concept called the backing bean, which is often referred to as the model, but isn't a pure model itself. Instead, it delegates to the real model (e.g. EJB services). The backing bean can also take up some controller responsibilities (issuing a redirect, or putting a message in a kind of queue for the view to display).
Sometimes it's thought that creating a web and business tier is overkill, but this absolutely doesn't have to be the case. It's often just a matter of applying sound OO principles. The other extreme, e.g. stuffing everything on a JSP (html code, controller logic AND business code) is far, far worse.
See this example of how simple a 3 tier (3 layer actually) Java EE MVC application can be: Minimal 3-tier Java EE app, without any XML config
A related question is this one: What are the main advantages of MVC pattern over the old fashioned 3-layer pattern
If you use servlets, it's already Java EE.
And don't make unnecessariliy complex. If you only have a web user interface and no other user interface, dividing into both a web and business tier is over-kill.

Resources