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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:20:46+00:00 2026-06-10T23:20:46+00:00

I have a servlet method where i need to pass a json object. This

  • 0

I have a servlet method where i need to pass a json object. This json object will be created in one of the managed bean(JSF). I just tried injecting the bean into the servlet to get the json object, but i am getting runtime exception, may be it is not possible that way. So i want to call the servlet from JSF bean. Any ideas how to call from the bean?

Servlet

private static final long serialVersionUID = 1L;
TopicController topicController;
TopicBean topicBean;
List<JsonTopicObj> jsonTopicList;
public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws IOException {

    // here code for subscription

    Meteor mateor = Meteor.build(req).addListener(
            new MyAtmosphereResourceEventListener());

    boolean isLongPolling = true;
    if (mateor.transport() == LONG_POLLING) {
        isLongPolling = true;
    } else {
        isLongPolling = false;
    }
    System.out.println(" Now in the Get method of Atmosphere");
    // create the broadcaster for the particular topic
    String topicId = "default"; // for all users right now
    Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(
            topicId, true);
    //set that broeadcaster
        mateor.setBroadcaster(broadcaster);
        mateor = mateor.resumeOnBroadcast(isLongPolling);
        mateor.suspend(-1);

}

    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws IOException {}

JSF BEAN

@ManagedBean(name = "testController")
@RequestScoped
public void listAllTopics() {
        JsonTopicObj jsonTopicObj;
        StringWriter out = new StringWriter();
        JsonFactory jfactory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper();
        jsonTopicList = new ArrayList<JsonTopicObj>();

        for (int i = 0; i < topicBean.getTopicVOArray().length; i++) {
            jsonTopicObj = new JsonTopicObj();
                   ......................

                         }
                   mapper.writeValue(out, jsonTopicList);  

now i need to call the servlet dopost method and send “out.toString()”

  • 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-10T23:20:47+00:00Added an answer on June 10, 2026 at 11:20 pm

    Where is your first control? Does it go to managed bean and then servlet
    and this bean is responsible for forwarding to the servlet? If it is so,
    you can create the JSON object, get your request and response from FacesContext
    and dispatch the request to the servlet.

    FacesContext give your request and response and from that you can dispatch your
    request.

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

Sidebar

Related Questions

I have a Document object initialized in the init() method of the servlet and
Hi I have a webapp - and in one method I need to encrypt
Am using JSF 1.2 . I have a servlet. When this servlet is hit,
I have a servlet which takes us to an existing jsp, say home.jsp. This
I have this servlet program and an external .jar file (written by someone else)
I have to pass some strings from a java servlet to a php script.
We currently have a Stateful bean that is injected into a Servlet. The problem
I have a simple servlet at the moment. I need it to call a
i need to call a servlet from javascript by using ajax post method and
I need help with servlet filters. At the moment we have ChangePassword servlet for

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.