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 8892119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:54:48+00:00 2026-06-14T22:54:48+00:00

I have an application that built using struts, spring, hibernate. In this application, i

  • 0

I have an application that built using struts, spring, hibernate. In this application, i want to built rest service. This rest service will be used for Android application. In this application, user and role was store in my database. Username and password in the user table and role in the role table.
What I want to ask, how to authenticate the client who wants to access the rest service. So to access the resource at rest service, the client must login first. If user have not logged in, then the rest will always returning String “not_authenticated” for example. Usually in web application, this using the session. Do the same with the rest?

edited to add my current code and to update my question

@POST
@Path("/login")
@Produces(MediaType.APPLICATION_JSON)
public Response login(@FormParam("username") String username,
        @FormParam("password") String password){
    MessageDto messageDto = customerService.autenticate(username, password);
    if(messageDto.getResult().equals("success")){
        return Response.ok(messageDto)
            .cookie(new NewCookie("customerId", messageDto.getMessage()))
            .build();
    }else{
        return Response.ok(messageDto)
                       .build();
    }
}

MessageDto is an object which has two variable String result and String message. For example when client success in log in, the json return is like this

{"result":"success","message":"1-admin"}

When client not success in log in

{"result":"error","message":"Your username is not registered"}
  • 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-06-14T22:54:49+00:00Added an answer on June 14, 2026 at 10:54 pm

    set a user cookies(like userId,token etc…) using your Jersey Response Object with HTTPONLY proprerty when login successful,

    and get that cookies using @CookieParam in your controller and verify with your database records first if match not found than redirect it to your login page otherwise go ahead.

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

Sidebar

Related Questions

I have an application built using PhoneGap (Android) that is essentially a shell for
I have built a web application using Java EE platform that sells one of
We have an application that we have built as a bundle and we want
I have this consumer targeted application that has built in error reporting. Sometimes I
I have an application that will accept URLs from the built in web browser
We have an application that is built with Excel as the front end using
I have an application that is built using ASP.NET, with an embedded Silverlight Object
I have a legacy VB6 application that was built using MSDE. As many client's
I have a web application that needs to be built using PHP/MySQL. The application
I have an application that is built as a Windows Service and a c#

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.