Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:03:50+00:00 2026-05-24T00:03:50+00:00

I was looking at a good REST tutorial using Jersey . Down the page,

  • 0

I was looking at a good REST tutorial using Jersey.
Down the page, there is a web resource that is built which is entitled TodoResource which itself contains two instance variables

public class TodoResource {
    @Context
    UriInfo uriInfo;

    @Context
    Request request;

    String id;

    public TodoResource(UriInfo uriInfo, Request request, String id) {
        this.uriInfo = uriInfo;
        this.request = request;
        this.id = id;
    }
}

I was wondering exactly how the UriInfo and Request instance variables are initialized? I know that using the @Context annotation allows for information to be injected, but at what point does this happen? Will this be handled automatically by Jersey?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:03:51+00:00Added an answer on May 24, 2026 at 12:03 am

    Jersey doesn’t modify the class, but it creates it on every request from the client.

    After the class constructor was invoked, the context fields are injected.
    (Should you try to access those fields inside the constructor, they will be null)

    In your case, the class wouldn’t need a specific constructor, so just:

    public TodoResource () {
        // in most cases the ctor stays empty.
        // don't do much work here, remember: the ctor is invoked at every client request
    }
    

    But inside methods (which represent web-resources) annotated with @POST, @GET, ... you would have access to context fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in speed, not good looking code, that is why I'm using array
I'm looking for good tutorial or really simple code to integrate mongokit and django
I am looking for a good ThreadPool implementation. I understand that the .NET ThreadPool
I'm looking into writing an PHP REST API that would allow registered users interact
I am specifically looking for an example which use a) WCF & REST. After
Is there any good JavaScript / jQuery plug-in that will 'quicklook' an image on
Is there a good resource for the rules around how the httpHandler path property
Looking for good project methodologies.Anyone got some good reference links..want to share.
I am looking for good methods of manipulating HTML in PHP. For example, the
I am looking for good templates for writing both technical and functional specs on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.