Note that there are some explanatory texts on larger screens.

plurals
  1. POKept getting Target Unreachable, identifier resolved to null in JSF web app
    primarykey
    data
    text
    <p>i have a simple problem here i am making a simple jsf web app that can upload file but i kept getting </p> <pre><code>Target Unreachable, identifier 'upload' resolved to null </code></pre> <p>here's my upload class</p> <pre><code>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; } </code></pre> <p>}</p> <p>and my index page</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;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" &gt; &lt;h:head&gt; &lt;title&gt;Facelet Title&lt;/title&gt; &lt;h:outputStylesheet name="css/jsfcrud.css"/&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;ui:composition template="./template.xhtml"&gt; &lt;ui:define name="body"&gt; &lt;h:form&gt; &lt;h:commandLink action="/contacts/List" value="Show All Contacts Items"/&gt; &lt;/h:form&gt; &lt;h:form enctype="multipart/form-data"&gt; &lt;t:inputFileUpload value="#{upload.uploadedFile}" /&gt; &lt;h:commandButton value="submit" action="#{upload.submit}" /&gt; &lt;h:messages /&gt; &lt;/h:form&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p></p> <p></p> <p>oh yeah, here's my web.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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"&gt; &lt;context-param&gt; &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt; &lt;param-value&gt;Development&lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;filter&gt; &lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt; &lt;filter-class&gt;org.apache.myfaces.webapp.filter.ExtensionsFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;/filter-mapping&gt; &lt;session-config&gt; &lt;session-timeout&gt; 30 &lt;/session-timeout&gt; &lt;/session-config&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;faces/login.xhtml&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; </code></pre> <p></p> <p>Sorry for the long delay here my face config.xml</p> <pre><code>&lt;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"&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;user&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;SimpleLogin.simpleLogin&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;bean&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;SimpleLogin.Upload&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;&lt;/managed-bean&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/login.xhtml&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-action&gt; #{simpleLogin.CheckValidUser} &lt;/from-action&gt; &lt;from-outcome&gt;fail&lt;/from-outcome&gt; &lt;to-view-id&gt;/resultforfail.xhtml&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;navigation-case&gt; &lt;from-action&gt; #{simpleLogin.CheckValidUser} &lt;/from-action&gt; &lt;from-outcome&gt;success&lt;/from-outcome&gt; &lt;to-view-id&gt;/index.xhtml&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;application&gt; &lt;resource-bundle&gt; &lt;base-name&gt;/Bundle&lt;/base-name&gt; &lt;var&gt;bundle&lt;/var&gt; &lt;/resource-bundle&gt; &lt;/application&gt; </code></pre> <p></p> <p>and my template</p> <pre><code> &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;h:head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;&lt;ui:insert name="title"&gt;Default Title&lt;/ui:insert&gt;&lt;/title&gt; &lt;h:outputStylesheet name="css/jsfcrud.css"/&gt; &lt;h:outputStylesheet name="css/cssLayout.css"/&gt; &lt;h:outputStylesheet name="css/default.css"/&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;div id="top"&gt; &lt;ui:insert name="top"&gt;Ini Header&lt;/ui:insert&gt; &lt;/div&gt; &lt;h1&gt; &lt;ui:insert name="title"&gt;&lt;/ui:insert&gt; &lt;/h1&gt; &lt;p&gt; &lt;ui:insert name="body"&gt;&lt;/ui:insert&gt; &lt;/p&gt; &lt;div id="bottom"&gt; &lt;ui:insert name="bottom"&gt;Ini Footer&lt;/ui:insert&gt; &lt;/div&gt; &lt;/h:body&gt; </code></pre> <p></p> <p>what is the problem ? do i not clearly state the upload class ? Any help is good :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload