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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:59:21+00:00 2026-05-27T22:59:21+00:00

i have a simple problem here i am making a simple jsf web app

  • 0

i have a simple problem here
i am making a simple jsf web app that can upload file
but i kept getting

Target Unreachable, identifier 'upload' resolved to null

here’s my upload class

package SimpleLogin;

import java.io.IOException;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import org.apache.commons.io.FilenameUtils;
import org.apache.myfaces.custom.fileupload.UploadedFile;

@ManagedBean
@RequestScoped
public class upload {

private UploadedFile uploadedFile;

public void submit() throws IOException {
    String fileName = FilenameUtils.getName(uploadedFile.getName());
    String contentType = uploadedFile.getContentType();
    byte[] bytes = uploadedFile.getBytes();

    FacesContext.getCurrentInstance().addMessage(null, 
        new FacesMessage(String.format("File '%s' of type '%s' successfully uploaded!", fileName, contentType)));
}

public UploadedFile getUploadedFile() {
    return uploadedFile;
}

public void setUploadedFile(UploadedFile uploadedFile) {
    this.uploadedFile = uploadedFile;
}

}

and my index page

<!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:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:t="http://myfaces.apache.org/tomahawk"
  >
<h:head>
    <title>Facelet Title</title>
<h:outputStylesheet name="css/jsfcrud.css"/>
</h:head>
<h:body>
     <ui:composition template="./template.xhtml">

        <ui:define name="body">
                <h:form>
                <h:commandLink action="/contacts/List" value="Show All Contacts Items"/>
            </h:form>

            <h:form enctype="multipart/form-data">
                <t:inputFileUpload value="#{upload.uploadedFile}" />
            <h:commandButton value="submit" action="#{upload.submit}" />
            <h:messages />
            </h:form>

        </ui:define>
     </ui:composition>              

oh yeah, here’s my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee /web-app_3_0.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</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>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>faces/login.xhtml</welcome-file>
</welcome-file-list>

Sorry for the long delay
here my face config.xml

<faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns /javaee/web-facesconfig_2_0.xsd">

<managed-bean>  
    <managed-bean-name>user</managed-bean-name>  
    <managed-bean-class>SimpleLogin.simpleLogin</managed-bean-class>  
    <managed-bean-scope>request</managed-bean-scope>  
</managed-bean>    

<managed-bean>
     <managed-bean-name>bean</managed-bean-name>
     <managed-bean-class>SimpleLogin.Upload</managed-bean-class>
     <managed-bean-scope>session</managed-bean-scope></managed-bean>

<navigation-rule>
    <from-view-id>/login.xhtml</from-view-id>
    <navigation-case>
        <from-action>
        #{simpleLogin.CheckValidUser}
        </from-action>
        <from-outcome>fail</from-outcome>
        <to-view-id>/resultforfail.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-action>
        #{simpleLogin.CheckValidUser}
        </from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>/index.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>
<application>
    <resource-bundle>
        <base-name>/Bundle</base-name>
        <var>bundle</var>
    </resource-bundle>
</application>

and my template

 <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
     <h:head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <title><ui:insert name="title">Default Title</ui:insert></title>
 <h:outputStylesheet name="css/jsfcrud.css"/>
 <h:outputStylesheet name="css/cssLayout.css"/>
 <h:outputStylesheet name="css/default.css"/>
    </h:head>

<h:body>
    <div id="top">
        <ui:insert name="top">Ini Header</ui:insert>
    </div>

    <h1>
        <ui:insert name="title"></ui:insert>
    </h1>
    <p>
        <ui:insert name="body"></ui:insert>
    </p>

    <div id="bottom">
        <ui:insert name="bottom">Ini Footer</ui:insert>
    </div>

</h:body>

what is the problem ? do i not clearly state the upload class ?
Any help is good 🙂

  • 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-27T22:59:21+00:00Added an answer on May 27, 2026 at 10:59 pm

    You have overridden the @ManagedBean by a <managed-bean> declaration on the faces-config.xml, however that <managed-bean> declaration has a different managed bean name, namely bean instead of upload.

    You have basically 3 options:

    1. Use #{bean} instead of #{upload} in your view.

    2. Rename the <managed-bean-name> in faces-config.xml from bean to upload so that you can use #{upload} in your view.

    3. Get rid of <managed-bean> altogether so that the @ManagedBean will be used. The managed bean name defaults to the bean class name with 1st char lowercased, thus #{upload} should work.

    For the remaining, you are not consistent with Java naming conventions. Please work on that as well. Package names should be all lowercase and class names should be CamelCase and start with uppercase.

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

Sidebar

Related Questions

I have a simple problem but no matter what I try I can't see
I have a very simple problem and a solution that will work, but I'm
here is a simple problem. I have a table of 500 rows and what
I have a simple stupid question. Here's the problem, for years, my company has
i have very simple problem. I need to create model, that represent element of
I have a simple problem that i cannot solve. I have a dictionary: aa
I have a simple problem but I am not sure how to solve it.
I'm making a simple test app that navigates a category tree. Whenever I try
I have a weird case here.... I'm making a simple magento module right now.
I'm making a simple call from a file that's included in various pages. $.post(

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.