Reputation: 1731
I have the following assignment I need to program using Jetty. I've done a bit of research into how Jetty works but I can't understand how I can have two applications running at once, as below it says I need to have two forms of URL: /student
and /course
.
I made a very simple web server before using com.sun.net.httpserver.HttpServer to host a page with multiple contexts (different pages based on different URLs) but I'm not sure how to emulate the same behavior in Jetty. Do I want to use multiple handlers, or a single handler with multiple contexts? How do I even implement multiple handlers or contexts? Every example I've seen seems to allow only the use of one context or one handler.
I'm not worried right now about the logic of the program. I just don't understand how to separate the logic into two accessible web apps. What type of object do I need to use to host multiple apps in one program?
Write a web application using the jetty framework that implements the following functionality. Alternative web frameworks can be used with the permission of the instructor (I will provide a signed permission note, if approved).
The application should allow for the creation and editing a student profile, the URL should start with /student. Additionaly the application should allow for the display of sections that a course is taught (similar to assignment 3). This URL for courses should start with courses. These two features are independent.
The student page should provide a form to register a student, a registered student must supply their name, student number, and contact information. Contact information should include their mailing address, and email address. The page must support creation and editing of the student's profile. Once the profile is created, the system must be able to edit all the fields. You should use fake data for testing.
The student's profile must be saved to the disk. You can serialize the Java class that contains the information and write it a file. This file should be consulted with the page is loaded by a browser.
The form data for the student page should be sent to the server using JSON. The contents of the form should be fetch from the server as a JSON message.
The student form application can be implemented using only one web page with javascript handling the form data which is sent and received using JSON. Thus your assignment must contain javascript code.
The URL for this application should start with /course. The courses page should provide a form with a course text field, a number text field, and a submit button. Once submitted the server should provide a list of all the sections for that course, or an error message if the course does not exist.
Upvotes: 0
Views: 712
Reputation: 1511
In Jetty (and nearly every other servlet engine), you deploy different web archives (.war files) into the web server.
With jetty you did this by creating your two applications and name them according to your URL, e.g. student.war and course.war These .war files will be placed in the $JETTY_HOME/webapps directory.
Btw: If you just start with JEE and servlet engines, you should start with a very simple application to become familiar with it.
Upvotes: 1