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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:33:27+00:00 2026-06-01T00:33:27+00:00

The code pasted below is a simple JSF program, with an idea of having

  • 0

The code pasted below is a simple JSF program, with an idea of having a command button(in JSP, a JSF component), which when clicked should display a message written in the managed bean, come back and display the message in JSP.

**perfectJSP.jsp**

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Page</title>
</head>
<body>
<f:view>
<h:form>
  <h:commandButton value="Click" actionListener="#{Test.clicked}"></h:commandButton>
</h:form>
</f:view>
<h3> This brings us to the end of the program </h3>
</body>
</html>

**Test**  (managed bean)
import javax.faces.event.*;
public class Test {
public void clicked(ActionEvent ae)
{
    System.out.println("This is from the bean class");
}
}

**web.xml**

<servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>
        javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>
        org.apache.myfaces.webapp.MyFacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>

**faces-config.xml**


<faces-config>
<managed-bean>
<managed-bean-name>Test</managed-bean-name>
<managed-bean-class>Test</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>

JBoss is the Application-server used. Unable to understand why the output is not generated.

  • 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-01T00:33:29+00:00Added an answer on June 1, 2026 at 12:33 am

    You’re printing the message to the stdout which usually ends up in the server log. This does not end up in the HTML response which is what the client is supposed to retrieve.

    If you want to display some message upon a JSF form submit, there are several ways:

    • Use FacesContext#addMessage() with <h:messages/>. E.g.

      <h:form>
          <h:commandButton value="Click" action="#{Test.clicked}" />
          <h:messages />
      </h:form>
      

      with

      public void clicked() {
          FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("This is from the bean class"));
      }
      
    • Conditionally render a component whenever the message is available. E.g.

      <h:form>
          <h:commandButton value="Click" action="#{Test.clicked}" />
          <h:outputText value="#{Test.message}" rendered="#{not empty Test.message}" />
      </h:form>
      

      with

      private String message;
      
      public void clicked() {
          message = "This is from the bean class";
      }
      
      public String getMessage() {
          return message;
      }
      

    Further, your managed bean class is not in a package. This is absolutely not recommended. Java classes which are supposed to be accessible by other Java classes must be placed in a package.


    Unrelated to the concrete problem: you’re working with JSP which is considered deprecated since JSF 2.0 almost 2.5 years ago. JSP has been succeeded by Facelets. Make sure that you’re reading up to date JSF books/tutorials. See also our JSF wiki page.

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

Sidebar

Related Questions

I have a plot (sample code pasted below) that I am trying to add
Firstly sorry for the long piece of code pasted below. This is my first
The code I have pasted below is meant to display images on the middle
In the code base I was maintaining I found this exact class, pasted below.
I pasted the code given in this link to a file called md5.js. http://www.webtoolkit.info/javascript-md5.html
For a rich text editor that has to handle pasted HTML code from MS
Pasted a piece of code from the shell script transfer.sh if [[ ${ld} -eq
I have two pages - a simple HTML code example page from a jQuery
I am getting error when I try to execute the simple tinylibxml program. OS
I created a sample form and code below to illustrate. I know i can

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.