Jax Rs First Service

Start course
Difficulty
Intermediate
Duration
1h 8m
Students
3
Ratings
5/5
starstarstarstarstar
Description

This course takes an in-depth look at Java API for RESTful Web Services, otherwise known as JAX-RS. We also run through some example exam questions that will be useful for anyone who wants to take Oracle's Java EE exam.

Learning Objectives

  • Understand the fundamentals of JAX-RS
  • Learn about the main concepts and components of JAX-RS

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

Transcript

Hello dear friends. In this video we will create our first service. Let's begin. First, open eclipse. File new dynamic web project. Give project name and select your server. Generate web xml and finish. Now we will change project to the maven project. Right click on project in configure. Select convert maven project. Now open palm xml file. In this file, we have to add our Jersey dependencies. First add dependencies tag. In this tag, we will add Jersey tags. I will copy Jersey dependency tags. Look, we have four dependency. You may be thinking, where can I find them? Open maven Repository website. Search Jersey, select core. Select any version. 

Now look, there are all different project types. We will work on maven. So we will copy this one. Now let's turn back palm xml. You may want to change the version in the future. Let's add another tag to change version numbers automatically. Properties. Now we will define a new tag. For example, Jersey packages. Let's give version number. Now we will set Jersey packages to all of the dependencies. That will be enough for us. If you want to change something in the future, you don't have to change everything. Simply changing this one will be enough. Build a project. Let's look jars. In java resources library there is a maven folder. Look into the folder, there are Jerseys to our files. Done. Also we have to adjust servlet mapping in web xml. Open web xml. Add servlet tag, servlet name, servlet class.

Also, we need parameters, init- param. Param value will be your package names. Load on startup. Now let's add mapping, servlet name, url-pattern. Done. Now we have access to any class with this web API URL. Now, let's define a new package. Now we will add our first service class named employee, path annotation. Let's call our service path 1st service. Now we need a method, like get name, return Charles dickens. Now this must be get. We will start to learn annotations in following videos. For now, only want to show you how service works. Produces media type, text plain. Done. Let's try. Great. Now we can see Charles dickens, and that means our application is working as intended. Done. That's all I have for now. In the next video, we will start to examine annotations with path path param and application Path. See you in the next video.

 

About the Author
Students
1300
Courses
64
Learning Paths
4

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics