Code Monkey home page Code Monkey logo

jv-web-practice's Introduction

Web practice. Implement JSP pages and their corresponding controllers

!Note: let's install Tomcat 9.0.50. If you decide to install version 10 and above, you should use a different dependency for servlets and JSTL as well.

  • To get the actual parameters of the database tables, run script from the resources/init_db.sql file in the Workbench.
  • Create a new controller: Implement creating a driver
  • Create a new controller: Display all drivers
  • Create a new controller: Implement creating a manufacturer
  • Create a new controller: Implement creating a car (with no drivers by default)
  • Create a new controller: Implement adding driver to car.

HINT: while implementing the last requirement, create just two fields on JSP where you will pass corresponding id values. You can redirect to /index page or any other page after your business login in doPost() method is applied.

Example how to implement adding driver to car:

public class AddDriverToCarController extends HttpServlet {    
    private static final Injector injector = Injector.getInstance("mate.academy"); // be careful with copy-paste
    private final CarService carService = (CarService) injector.getInstance(CarService.class);
    private final DriverService driverService = (DriverService) injector.getInstance(DriverService.class);
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Long driverId = Long.valueOf(request.getParameter("driver_id"));
        Long carId = Long.valueOf(request.getParameter("car_id"));
        Car car = carService.get(carId);
        Driver driver = driverService.get(driverId);
        // continue your implementation 
    }
}

Typical mistakes:

  • Do not forget to import additional maven library for jstl
  • Do not forget to declare taglib prefix where applicable

Advanced:

  • Create a new controller: Display all manufacturers with ability to delete a certain manufacturer
  • Display all drivers with ability to delete a certain driver
  • Create a new controller: Display all cars (with manufacturer and drivers) with ability to delete a certain car

Before submitting solution make sure you checked it first with checklist

jv-web-practice's People

Contributors

resci avatar issugy avatar nick97-git avatar sofasmile avatar romandubovskyi avatar kseniiamakarova avatar max-pochepets avatar dskarzh avatar noct2000 avatar boroda4436 avatar maliukdaria avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.