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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:06:47+00:00 2026-05-11T09:06:47+00:00

I have two systems I’m trying to integrate. One is built on raw servlets,

  • 0

I have two systems I’m trying to integrate. One is built on raw servlets, the new one is build on JSF with IceFaces. I’m trying to facilitate cross-system sign on. The idea is that I have a button in the old system that POSTs the appropriate information to the new site and logs them on.

Well, ideally, I’d like to use just a regular old servlet to facilitate that on the new site. Go to the new site’s Servlet, do what it needs to do and the forward onto the dashboard.

Our security is handled via a managed bean. However, by the time you get to the Servlet, there is no faces context. So, how would I create a new faces context?

I have a back up plan in that I can always link to a dummy .iface page which will create the FacesContext for me and then create a backing bean that will do stuff when it gets instanciated and then forward onto the main page. But this feels very much like a hack.

Any help would be appreciated!

EDIT: I went with the back up way. Basically, I POST to a page like so:

<f:view>    <ice:outputText value='#{EntryPoint}'/> </f:view 

The backing bean looking like so…

public EntryPoint() {       try {          HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();          HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();           String loginID = request.getParameter('loginID');          //Do some code to load the user/permissions          response.sendRedirect(             //The appropriate page          );       } catch (IOException ex) {          logger.error(null, ex);       } catch (SQLException ex) {          logger.error(null, ex);       }    } 

This still feels like a hack, but I’m not sure how to get around this. Ideally, I’d POST to a servlet, get the loginID, build the user and put it directly into the managed bean. But, the FacesContext does not exist at that point.

Any other ideas?

  • 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. 2026-05-11T09:06:48+00:00Added an answer on May 11, 2026 at 9:06 am

    I’m not sure what you mean by ‘site’ in this context.

    A couple of notes:

    • Managed beans will be never be available outside the web app (WAR) in which they are defined.
    • FacesContext object instances are ultimately created and disposed by FacesServlet.service, so requests should pass through this servlet. Attempting to create a context under other circumstances might lead to undefined behaviour.

    Bearing that in mind, you could create a request sequence like this:

    FacesServlet (mapping: /faces/*)  -> /faces/jsfPage.jsp (a JSP with JSF controls)     -> DispatchBean (calls ExternalContext.dispatch('/AnotherServlet')        -> AnotherServlet 

    jsfPage.jsp contains:

    <f:view>     <h:outputText value='#{dispatchBean.dispatch}' /> </f:view> 

    The ‘dispatch’ property resolves to a bean method ‘getDispatch’:

    public String getDispatch() {     FacesContext context = FacesContext.getCurrentInstance();     try {         context.getExternalContext().dispatch('/FacesClientServlet');     } catch (IOException e) {         throw new FacesException(e);     }     return null; } 

    Which dispatches to this servlet:

    public class FacesClientServlet extends javax.servlet.http.HttpServlet         implements javax.servlet.Servlet {      static final long serialVersionUID = 1L;      @Override     protected void doGet(HttpServletRequest request,             HttpServletResponse response) throws ServletException, IOException {          FacesContext context = FacesContext.getCurrentInstance();         ELContext elContext = context.getELContext();         ExpressionFactory expressionFactory = context.getApplication()                 .getExpressionFactory();         ValueExpression expression = expressionFactory.createValueExpression(                 elContext, '#{myBean.text}', Object.class);         Object value = expression.getValue(elContext);          ResponseWriter writer = context.getResponseWriter();         writer.write('' + value);      }  } 

    Which emits the value from a managed bean ‘myBean’:

    public class MyBean {      private final String text = 'Hello, World!';      public String getText() {         return text;     }  } 

    This is all very convoluted and I wouldn’t willingly do any of it.


    An alternative, which may come with its own consequences, is to create your own context like this:

    public class ContextServlet extends javax.servlet.http.HttpServlet implements         javax.servlet.Servlet {     static final long serialVersionUID = 1L;      private FacesContextFactory facesContextFactory;     private Lifecycle lifecycle;      @Override     public void init(ServletConfig config) throws ServletException {         super.init(config);          LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder                 .getFactory(FactoryFinder.LIFECYCLE_FACTORY);         facesContextFactory = (FacesContextFactory) FactoryFinder                 .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);         lifecycle = lifecycleFactory                 .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);     }      @Override     protected void doGet(HttpServletRequest request,             HttpServletResponse response) throws ServletException, IOException {          FacesContext context = facesContextFactory.getFacesContext(                 getServletContext(), request, response, lifecycle);         try {             ELContext elContext = context.getELContext();             ExpressionFactory expressionFactory = context.getApplication()                     .getExpressionFactory();             ValueExpression expression = expressionFactory                     .createValueExpression(elContext, '#{myBean.text}',                             Object.class);             Object value = expression.getValue(elContext);              PrintWriter pw = response.getWriter();             try {                 pw.write('' + value);             } finally {                 pw.close();             }         } finally {             context.release();         }     }  } 

    Again, I would avoid this approach if possible.

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

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Short answer... it depends. Session in ASP.NET can be stored… May 11, 2026 at 9:39 pm
  • Editorial Team
    Editorial Team added an answer From The Haskell 98 Foreign Function Interface 1.0, Dynamic import.… May 11, 2026 at 9:39 pm
  • Editorial Team
    Editorial Team added an answer try this: #ifdef debugmode #define DEBUG(cmd) cmd #else #define DEBUG(cmd)… May 11, 2026 at 9:39 pm

Related Questions

I have two systems I'm trying to integrate. One is built on raw servlets,
I have two Slackware Linux systems on which the POSIX semaphore sem_open() call fails
I have an application that uses simple sockets to pass some characters between two
I will be entering my third year of university in my next academic year,
If you take a look at the clock_gettime() function, which is available in all

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.