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

  • SEARCH
  • Home
  • 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 8465985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:12:32+00:00 2026-06-10T15:12:32+00:00

Sorry, I am just starting with all this EJB, JSF and JAX-RS stuff and

  • 0

Sorry, I am just starting with all this EJB, JSF and JAX-RS stuff and need your help now.
I have created a JAX-RS Resource class, which works very well and implements @GET, @PUT, etc. Methods.

In the same project I now created a JSF page with the according BackBean. This Backbean should talk to the REST interface. While testing, I hardcoded the URI of the REST Interface into the bean, but of course I would like to get the URI programmaticly. I tried with a @Produces method and injection, but I always get an IllegalStateException. I think this has to do with contexts, but I actually do not have the understandning to solve it.

My REST Resource:

@Path("task")
@ManagedBean
@RequestScoped
public class TaskResource {

@Context
private UriInfo context;

@Inject TaskLifecycle lc;

public TaskResource() {
}

@GET
@Path("{id}")
public Response getTask(@PathParam("id") String id)  { ... etc.

My Backbean:

@ApplicationScoped
@LocalBean
@Named("tmmlWrapper")
public class TmmlTaskWrapperBean implements Serializable {

// Here another ManagedBean is injected, which works fine!
@Inject TaskLifecycle       lc;

and finally my JSF Page:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <title>Tasklist</title>
</h:head>
<h:body>
    <h:form>
        <h:outputLabel ><h3>Tasklist:</h3></h:outputLabel>

        <h:dataTable value="#{tmmlWrapper.taskList}" var="tl">

        <h:column>

            <f:facet name="header">ID</f:facet>
            #{tl.id}

        </h:column> ... and so on ... etc.

My question:
How can my BackBean get the URI of the REST resource (ex. “http://exampledomain:8080/as&#8221;)?
Any help is welcome!

Cheers,
Joern

  • 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-10T15:12:34+00:00Added an answer on June 10, 2026 at 3:12 pm

    You’ll first need to get access to the underlying servlet container (assumed to one, instead of a portlet container) produced HttpServletRequest object. Use the FacesContext object to access the HttpServletRequest object in the following manner:

    HttpServletRequest origRequest = (HttpServletRequest)FacesContext.getExternalContext().getRequest();
    

    The HttpServletRequest class provides several utility methods to obtain a near representation of the original request:

    • getRequestURL(), which provides the original request sans the query string
    • getScheme, getServerName, getServerPort, getContextPath, getServletPath, getPathInfo and getQueryString all of whose outputs can be combined in sequence to obtain the original request. You may have to omit the latter invocations if you want a lesser fragment of the URL.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just starting out C++, so sorry if this is a dumb question.
Sorry if this is quite noobish to you, but I'm just starting out to
Sorry for my bad English. Just like what I asked. I have this class
Just starting with php and sorry if this is a newbie question but i'm
Just starting to learn the Java side of things, sorry if this is obvious.
Sorry if this is kind of a noob question, but I'm just starting to
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
everyone. I'm just starting with django, so sorry for a possibly stupid question. Imagine,
Sorry if its just me who is scratching the head looking at this code,
Sorry if this is dumb but I was just thinking I should give a

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.