Jessai
Jessai

Reputation: 947

What should I use instead of jsp:useBean?

Recently I've read some articles and SO answers, where suggests we should avoid the use of jsp:useBean tag to communicate from the View Layer to the Controller layer. I'm developing a View layer with JSTL and I want to know:

How to access a bean/servlet method from the view layer without the jsp:useBean tag?

UPDATE

I was thinking in a Servlet as a bean, put it in1 jsp:useBean and then use its methods and vars, but it seems the tag is becoming old, that's why I want to see alternatives to use beans or servlets or Am I misunderstading the use of the tag?

Upvotes: 4

Views: 3427

Answers (1)

Gyanendra Dwivedi
Gyanendra Dwivedi

Reputation: 5538

If you are using <jsp:useBean> in your application, it means your view is directly interacting with model data and controller here might not be playing any role. It would be like MV model (rather than MVC).

In MVC approach the request/response object is used to pass data between view and controllers; which in turn forwarded to model beans (model beans hold the business logic to be operate on data).

I would suggest to use JSP implicit objects to pass on data between layers. Further using a framework like Spring MVC here makes more sense, as it will make your life easy and hide the complexities of app flow control.

Upvotes: 2

Related Questions