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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:45:19+00:00 2026-05-23T03:45:19+00:00

I want to fill an selectOneMenu with fields from my DataBase and then use

  • 0

I want to fill an selectOneMenu with fields from my DataBase
and then use the chosen value in another request SQL.
For know I have my selectOneMenu filled from my data but I dont Know how to retrieve the chosen value and show it into another page. The error is:
org.apache.jasper.JasperException: An exception occurred processing JSP page /Result.jsp
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)

Also I want to write a clean code , I want to create class connection and use it to connect one time in the first page and deconnect at the last page(when I finish).

Bean:

public class BeanTools {

  private List<SelectItem> mesElements;
  private  String maValeur;
  public PreparedStatement st;
  Connectionx con = new Connectionx();  **//IF I do that on N page I will have N connection!!**
  Connection cx = (Connection) con.Connx();

      public BeanTools() {
    }     

    public String getMaValeur() {
        return maValeur;
    }

    public void setMaValeur(String maValeur) {
        this.maValeur = maValeur;
    }

    public void setMesElements(List<SelectItem> mesElements) {
        this.mesElements = mesElements;
    }




public Iterable<String> remplireItem() throws ClassNotFoundException, SQLException
    {

String sql;
sql ="select issuestatus.pname from issuestatus;";
System.out.println("sql");
st=(PreparedStatement) cx.prepareStatement(sql);
ResultSet rs1 = st.executeQuery();System.out.println("execute");

String nbb;
ArrayList<String> list = new ArrayList<String>();
while(rs1.next())
      {
          nbb = rs1.getString("pname");
          System.out.println(nbb);
          list.add(nbb);
          System.out.println("list"+list.toString());
      }


return list;
    }


public List<SelectItem> getMesElements() throws SQLException, ClassNotFoundException {

if (mesElements == null) {
mesElements = new ArrayList<SelectItem>();
for (String val : remplireItem()) {
mesElements.add(new SelectItem(val));
}
}
return mesElements;
}
}

First JSF page:

<h:form id="form">       
 Issue status 2 :<h:selectOneMenu style="width:200px"  value="#{BeanTools.maValeur}" >
     <f:selectItems value="#{BeanTools.mesElements}"/>
                 </h:selectOneMenu>

 <h:commandButton action="submit" value="submit"/>
 </h:form>

Second JSF page:

<body>      
        <h:outputText  value="#{BeanTools.maValeur}" />

</body>

The Faces config:

<managed-bean>
<managed-bean-name>BeanTools</managed-bean-name>
<managed-bean-class>KPIs.BeanTools</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<navigation-rule>
<from-view-id>/welcomeJSF.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/Result.jsp</to-view-id> 
</navigation-case>
</navigation-rule>

Class Connection:

public class Connectionx {

public Connection cx=null;
public Statement st;

 public Connectionx() {}

public Connection Connx()
{

  System.out.println("enregister le driver");
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch( Exception ex )
                {
                System.err.println("Erreur lors du chargement du driver"+ex.getMessage() );


                }


        try {
            /** Connection  */
             cx =  (Connection) DriverManager.getConnection           ( "jdbc:mysql://localhost/jiradb","","" );

                }
                catch( SQLException ex )
                {
            System. err. println( "Error ")                }
  return cx;
}

The whole stacktrace:

org.apache.jasper.JasperException: An exception occurred processing JSP page /Result.jsp at line 19

16:     <body>
17:         <h1>Hello World!</h1>
18:       
19:         <h:outputText   value="#{BeanTools.maValeur}" />
20:        
21:     </body>
22: </html>


Stacktrace:
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:363)
    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Component javax.faces.component.UIViewRoot@144c984 not expected type.  Expected: javax.faces.component.UIOutput.  Perhaps you're missing a tag?
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:907)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
    at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:84)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
    ... 38 more
Caused by: java.lang.IllegalStateException: Component javax.faces.component.UIViewRoot@144c984 not expected type.  Expected: javax.faces.component.UIOutput.  Perhaps you're missing a tag?
    at com.sun.faces.taglib.html_basic.OutputTextTag.setProperties(OutputTextTag.java:126)
    at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:690)
    at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1311)
    at com.sun.faces.taglib.html_basic.OutputTextTag.doStartTag(OutputTextTag.java:163)
    at org.apache.jsp.Result_jsp._jspx_meth_h_005foutputText_005f0(Result_jsp.java:103)
    at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:73)
    ... 41 more
  • 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-05-23T03:45:20+00:00Added an answer on May 23, 2026 at 3:45 am

    Finally, there’s the root cause of the exception:

    Caused by: java.lang.IllegalStateException: Component javax.faces.component.UIViewRoot@144c984 not expected type. Expected: javax.faces.component.UIOutput. Perhaps you’re missing a tag?

    You forgot the <f:view> in Result.jsp. All JSF components has to go inside a <f:view>. Edit your Result.jsp so that it look like the following basic template:

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html>
    <f:view>
        <html lang="en">
            <head>
                <title>JSP page</title>
            </head>
            <body>
                <h:outputText value="JSF components here." />
            </body>
        </html>
    </f:view>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to fill a GridView with data from a database and let the
i want to fill the data of the charts from values i have in
I want to fill a ListFragment with certain objects loaded from my MySql database.
I want to fill a DataGridView with data returned from a SQL. So here
I have two fields I want to fill with the exactly same values; users
So when i have a Datagrid which i want to fill with data from
i want to fill a combobox with data from the database when the page
I want to fill jqGrid from a stored procedure, there was 1 good example
I want to fill all cells with the same control. What I have now
I simply want to fill-up cells in my spreadsheet from a VBA function. By

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.