title: java.lang.NumberFormatException: For input string: "pname"
body: <p>why I always get numberformatexception?
  I try to retrieve values in my database to my jsp.
  I want to view my join table in my jsp.</p>
  
  <p>I have 2 entities</p>
  
  <p>Item Class</p>
  
  <pre><code>public class Item {
  
  @Id
  @Column(name="p_id")
  private String pid;
  
  @Column(name="p_name")
  private String pname;
  
  
  @Column(name="catId")
  private String catid;
  
  public String getPid() {
      return pid;
  }
  
  public void setPid(String pid) {
      this.pid = pid;
  }
  
  public String getPname() {
      return pname;
  }
  
  public void setPname(String pname) {
      this.pname = pname;
  }
  
  public String getCatid() {
      return catid;
  }
  
  public void setCatid(String catid) {
      this.catid = catid;
  }}
  </code></pre>
  
  <p>Category Class</p>
  
  <pre><code>public class Category {
  
  @Id
  @Column(name="c_id")
  private int cid;
  
  @Column(name="catId")
  private String catid;
  
  @Column(name="c_name")
  private String cname;
  
  @Column(name="c_brand")
  private String cbrand;
  
  public int getCid() {
      return cid;
  }
  
  public void setCid(int cid) {
      this.cid = cid;
  }
  
  public String getCname() {
      return cname;
  }
  
  public void setCname(String cname) {
      this.cname = cname;
  }
  
  public String getCbrand() {
      return cbrand;
  }
  
  public void setCbrand(String cbrand) {
      this.cbrand = cbrand;
  }
  
  public String getCatid() {
      return catid;
  }
  
  public void setCatid(String catid) {
      this.catid = catid;
  }}
  </code></pre>
  
  <p>btw catId in my Item class is a foreign key to Category.</p>
  
  <p>I try to create hql in my DaoImpl and joined the two tables it looks like this</p>
  
  <pre><code>public List&lt;Item&gt; getItem() {
      EntityManager entityManager = transactionManager.getEntityManagerFactory().createEntityManager();
      Query sqlQuery = entityManager.createQuery("SELECT i.pname,c.cname,c.cbrand FROM Item i,Category c where i.catid= c.catid");
  
      List&lt;Item&gt;iList = sqlQuery.getResultList();
      if (entityManager.isOpen())
          entityManager.close();
  
      return iList;
  }
  </code></pre>
  
  <p>@Controller </p>
  
  <pre><code>    @RequestMapping(value = "/list")
  public String result(HttpServletRequest request, ModelMap map) {
  
      List&lt;Item&gt; iList = catService.getItem();
      map.addAttribute("iList", iList);
  
      return "new/list";
  }
  </code></pre>
  
  <p>@my view jsp looks like this</p>
  
  <pre><code>&lt;c:if test="${not empty iList}"&gt;
          &lt;table border="1"&gt;
          &lt;tr&gt;
  
              &lt;th&gt;Product name&lt;/th&gt;
              &lt;th&gt;Category&lt;/th&gt;
              &lt;th&gt;Brand&lt;/th&gt;
  
              &lt;c:forEach var="p" items="${iList}"&gt;
  
                      &lt;td&gt;${p.pname}&lt;/td&gt;
                      &lt;td&gt;${p.cname}&lt;/td&gt;&lt;td&gt;${p.cbrand}&lt;/td&gt;
  
              &lt;/c:forEach&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  &lt;/c:if&gt;
  </code></pre>
  
  <p>and i always get this error:</p>
  
  <pre><code>Stacktrace:] with root cause
  java.lang.NumberFormatException: For input string: "pname"
      at java.lang.NumberFormatException.forInputString(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:158)
      at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:45)
      at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
      at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
      at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
      at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:967)
      at org.apache.jsp.pages.new_.list_jsp._jspx_meth_c_005fforEach_005f0(list_jsp.java:243)
      at org.apache.jsp.pages.new_.list_jsp._jspx_meth_c_005fif_005f0(list_jsp.java:204)
      at org.apache.jsp.pages.new_.list_jsp._jspService(list_jsp.java:98)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
      at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>can someone help me with this problem? thanks in advance!</p>