Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:44:54+00:00 2026-06-17T16:44:54+00:00

Am trying a project in JSP using MVC pattern. In online tutorial, it had

  • 0

Am trying a project in JSP using MVC pattern.

In online tutorial, it had a servlet as a controller which in its doPost() method:

  • accesses data from model
  • puts it in request scope and finally
  • redirects to view (a JSP page)

The JSP page then accesses the parameter added in request scope and displays the content of that object in the desired layout.

Q1:
However in this approach there will be one controller per view, I mean for every JSP there will be one servlet. Is that good practice? Or I should have single controller for many views and have views send a command value to controller through header which controller will use to decide what to access through model and what view to generate next.

Q2:
Does servlets is the standard way to implement Controller? What are other options to build controllers? What is more commonly used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:44:56+00:00Added an answer on June 17, 2026 at 4:44 pm

    This is the same question when I am entering Java EE in early days 😉

    Seems you have already directly mapped the concept of controller to servlet, which may be true on your sample project. But for a more realistic project, this is hardly true and maintainable. So for my following answer, please do bear in mind, controller and servlet are two different concepts, and I intent to answer your second questions first.

    Q2:

    Since servlet mapping must be hard coded in web.xml, which is very bothering(I mean, you prefer to write Java code then XML stuff, right?), nowadays mainstream MVC framework(struts, Spring MVC, etc) all take a similar single “dispatcher” servlet practice.

    This servlet bootstrap the framework, load your custom controllers, then your whole application is alive. This dispatcher servlet is in charge of finding the correct controller, based on different request paths, query parameters, you name it.

    Q1:

    For one controller per view, or one controller to multiple views, there is no single best practice on that. My suggestion is as long as you can keep your code clean and consistent, choose whatever strategy suitable for your project. After all, this is a taste of orgnazing your code.

    Controller and view are two different layers to separate problems of concerns, right?

    BTW, I strongly recommend you to pick up whatever mainstream MVC framework’s design document, I think they can do a quite better job to explain your puzzles.

    External reference:

    http://www.jpalace.org/docs/articles/mvc/mvc.html This is a great article on implement a dispatch servlet. It actually build a very small but complete framework using the MVC design pattern.
    http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html The chart on it explains well what a dispatcher servlet does in the framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am creating a web project using JSP, and is trying to implement a
ím trying to add jstl/jsp component to a spring+flex+hibernate project. Im using Tomcat 5,
Im trying to compile this project h__p://ross-warren.co.uk/my-twitter-clone-using-jsp-and-cassandra/ I have downloaded it, and spend almost
I am trying to solve Project Euler problem in Clojure using recursion. The following
I am working with jsp/servlet project and I have to complete the module of
Hi Im a complete novice when it coems to using JSP. Im trying to
I am fairly new to Servlet Filters and have basically joined a project using
I am working on a project to take an existing project using JSF1.2, JSP,
I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using
I'm trying to upload images in JSP using Apache Common FileUpload with Spring/hibernate. Uploading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.