How To Setup Jetty Server in Java 8 Web Application. - State of Software Engineering (#SOSE4)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi my name is Emily and today I would like to show you how you can embed a jetty server in a java web application at first we will create a maven project going on creating the maven module for the jetty server adding some servlets and then going over to creating the web application module this one will be very easy very simple just containing a simple index HTML web page at the end we'll build the war file and connect it to the jetty server ok let's create a new project and we will call it my jetty ok the first step is done we have our project here's a source folder because we are building some or exactly two maven modules we don't need this source folders so I will just delete it [Applause] [Music] [Applause] [Music] right click on the server new module I chose maven pray from archetype we're gonna have the Quick Start and we call it server okay okay just renaming it refactor rename and call it check the server not didn't work okay um just make it a bit nicer okay so our new server and you wanna call it 8080 here we will do some stuff and at the end we want to start the server and since it can take some time if we do a lot of things here we're gonna wait until everything is up and running before we join the server right so the first thing is we have to import something just the jetty server library since we doesn't have it right now we have to who have to add a maven dependency to that and we find it in the somewhere in Eclipse okay sir and most of all it's enough to take the jetty server but since we want to connect it to war and I'm not sure if it inside this library I'm going for for this one oh sorry for this one great it's downloaded we can import it great [Applause] [Music] [Applause] the next thing is and we need a handler for it and we need the handler to tell them the context path and and the class we want to write our code so I chose a serve that handler handler so hand sir wait just edit and at the end I would like to tell the server what my handler is ok and now we have to do something I want to add servlet mapping and I need for that a class and we call it ping handler class and please listen that ping and since we doesn't have the ping Handler and right now we're just trade a ping handler class right here and for that we we extend it because we want to have it as a servlet handler we will abstract it or we will extend it from an HTTP server let's just look inside that one and I think we go far to get I hope I copied the to get from HTTP servlet let's just see yes we worked let's just remove everything into it and make it totally from scratch okay we have a request and we have response and let's take the response and set the status to Oh Kay just go down did you see okay there it is and then we set the response and get the writer because we're gonna write something returns up in writer or it out just have to import it out dot and print something out let's make a hitter and type the ping handler class does get name great now we have that let's get back to our jetty server something that he doesn't like cannot resolve that one that's very weird to shoot actually at okay just see it's a servlet with mapping like that not working great okay hmm something else it's not working so the first version of it is ready I think we should just run it and check it out for that run the meantime I will just start chromed so will not lose any time localhost and we say 8080 and ping it's not working because it's not finished yet okay it started pressing 5 and now we see it the paint handler right okay [Applause] and the next thing is that we will add another maven module for the web application creating also an archetype the web app but not that one sorry web app there this next and call it web app great so but now I have the web application and inside we have an index JSP that will just just rename and same HTML that just take a look it's this one here so it will pay the bill the war file and it's nothing in there we don't need anymore so heading over to the jetty server I wanna just hide this one so what great [Music] [Applause] and now if I set web app safe it give this server that one we will comment out for now creating the method for that and now we were at the web app context web app this context at the end we have to set the depth handler right and record a new web app and we now wanna give it a the war file and the war file needs an absolute path so we will say new file and it's in the module called web app and will be grid on rhetoric and the main you will be the name of the module since we didn't say anything that's war and then since it wants an absolute path would say that then we need to set the context path as well let's say web ok that's basically it now we want to run maven clean install to build the war file so heading over to my directory and wasn't it inside here sorry why Chetty maven the door that would be it I hope yes that was success and let's try to run it no it's not running the whip and war should be should be here sorry it's here whip app target web app war set context pop sorry to that forgot the slash once more okay now it works great I hope you liked the video if you liked it and if you get an idea about how you can create a simple jetty web application please like this video or follow me thank you very much
Info
Channel: DEVREAL Azure
Views: 17,559
Rating: undefined out of 5
Keywords: java, java 8, introduction, jetty server, embedded jetty, sose, sose4
Id: rBcwbsEFcVI
Channel Id: undefined
Length: 15min 11sec (911 seconds)
Published: Thu Nov 23 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.