Git Product home page Git Product logo

teaching-heigvd-amt-mvc-simple-example's Introduction

Teaching-HEIGVD-AMT-MVC-simple-example

A very simple example to demonstrate the MVC pattern with servlets and JSPs

WARNING

  1. There is an issue with the latest version of Payara Server, depending on the Java Version that you are using. You might get an error about the keystore if you are subject to this issue. The way to address it is to use JDK 11 both for running the application server AND for running asadmin (which IntelliJ is doing behind the scenes). Make sure to configure your IntelliJ Project and to select JDK 11 as the SDK.

Getting started

  1. Open the project in IntelliJ
  2. You should see a popup saying "Maven projects need to be imported": click on "Enable Auto-Import"
  3. Check that you can build the project: in the "Maven Projects" pane, open "Lifecycle" and double-click "install". You should logs messages in the output console. Maven should create a targetdirectory, in which you should see a file named mvc-simple.war.
  4. Define one more "Run configurations":
    1. In the menu, select Run > Edit Configurations...
    2. Click on the + icon
    3. Select Glassfish Server > Local
    4. Give a name to the run configuration: "Run with Glassfish (local)"
    5. Assuming that you have downloaded the Glassfish version provided by Payara, you should be able to select the directory where you unpacked it by clicking on "Configure..."
    6. In the panel "Glassfish Server Settings", select the "domain1" domain
    7. At the bottom of the screen, you should see a red warning: No artifacts marked for deployment:
      1. Click on Fix
      2. Select the xxx:war explodedartifact (more practical than the xxx:warfor developement)
      3. Click on Apply
    8. In the On 'Update' action drop-down, select Redeploy. With this setting, when you do a reload, the application will be redeployed in the application server.
    9. In the On frame deactivation, select Update resources and classes. With this setting, when you switch from IntelliJ to another application (typically the browser), the IDE will hot deploy your code modifications. This depends on the application server and likely to work only in Debug mode.
  5. Start the configuration in "Debug" mode: Run > Debug 'Run with Glassfish (local)' (warning: the ports used by Glassfish, 8080 and 4848 by default, need to be free. Watch out for running Docker containers and other projects).
  6. Intellij should build the project, start Glassfish and deploy the application. It should then open your web browser and load the page http://localhost:8080/mvc-simple/. You should see a Hello World! message. Type the following URL in the browser: http://localhost:8080/mvc-simple/quotes. You should now see a page showing a list of 3 quotes, with their author.
  7. Test if Hot Reload work:
    1. Open the QuoteGenerator class
    2. Modify the code to add an extra quote.
    3. Go back to the browser (this triggers a 'frame deactivation') and reload the page
    4. You should now see 4 quotes in the list.
  8. Test the debugger
    1. Add a breakpoint in the doGetmethod of the QuoteServlet class.
    2. Reload the page in the browser and verify that you the breakpoint works and that you can inspect variables.
    3. Do the same thing in the view.jsp file: the debugger also works in Java Server Pages!
  9. You can apply the same process for Wildfly (JBoss) and TomEE.

teaching-heigvd-amt-mvc-simple-example's People

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.