Reputation: 5
New to jsp and servlets in general. I've learned that I can skip url-mapping in web.xml
by applying a @WebServlet
annotation to a servlet. Its also my understanding that what a jsp file is, is something that is compiled down to a servlet at execution time. Is it possible to also apply an @Webservlet
annotation to a jsp file, such that the resultant servlet is already mapped, and I don't have to create url-mapping tags in web.xml for all my .jsp files?
Thanks for any info!
Upvotes: 0
Views: 1885
Reputation: 1058
Annotation @Webservlet
can be applied only to Servlet(java class).
If you want to get access to jsp, it's can be reach by two way:
But add business logic to jsp is a bad practice. JSP responsible only for view part of MVC pattern
.
Model-View-Controller (MVC) is a pattern used in software engineering to separate the application logic from the user interface. As the name implies, the MVC pattern has three layers.
Model Layer
This is the data layer which contains business logic of the system, and also represents the state of the application
The Controller Layer
Controller layer acts as an interface between View and Model. It receives requests from the View layer and processes them, including the necessary validations.
The View Layer
This layer represents the output of the application, usually some form of UI. The presentation layer is used to display the Model data fetched by the Controller.
Upvotes: 1