MySQLSyntaxErrorException: - mysql

Whenever I try to insert values in form it gives error...
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'regno' in 'field list'com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'regno' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:939)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2547)
at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1541)
at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2605)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1469)
at org.apache.jsp.insertRegister_jsp._jspService(insertRegister_jsp.java:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
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:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
My JSP file registerVehicles.jsp is ...
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Example</title>
</head>
<body>
<form method="post" action="insertRegister.jsp">
<center>
<table border="1" width="30%" cellpadding="3">
<thead>
<tr>
<th colspan="2">Register New Vehicle</th>
</tr>
</thead>
<tbody>
<tr>
<td>Vehicle Registration Number</td>
<td><input type="text" name="vrn" value="" /></td>
</tr>
<tr>
<td>Manufacturer</td>
<td><input type="text" name="maker" value="" /></td>
</tr>
<tr>
<tr>
<td>Model</td>
<td><input type="text" name="model" value="" /></td>
</tr>
<tr>
<td>Manufactured Date</td>
<td><input type="date" name="mfd" value="" /></td>
</tr>
<tr>
<td>Fuel Type</td>
<td><input type="text" name="ft" value="" /></td>
</tr>
<td><input type="submit" value="submit" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
</tbody>
</table>
</center>
</form>
</body>
</html>
insertRegister.jsp
<%# page import ="java.sql.*" %>
<%#page import="java.io.*, java.util.*,java.text.*"%>
<%
String vrn=request.getParameter("vrn");
String maker=request.getParameter("maker");
String model=request.getParameter("model");
String mfd=request.getParameter("mfd");
String ft=request.getParameter("ft");
java.util.Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("dd-mm-yyyy ");
String currDate = dateFormat.format(date);
Calendar c = Calendar.getInstance();
c.setTime(new java.util.Date()); // Now use today date.
c.add(Calendar.DATE, +90);
String validDate = dateFormat.format(c.getTime());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/puc", "root", "root");
Statement st=conn.createStatement();
int i=st.executeUpdate("insert into login(regno,maker,model,made_year,fuel_type,curr_date,vaalid_to)"+"values('"+vrn+"','"+maker+"','"+model+"','"+mfd+"','"+ft+"','"+currDate+"','"+ validDate +"')");
out.println("Data is successfully inserted!");
}
catch(Exception e)
{
System.out.print(e);
e.printStackTrace();
}
%>
Can someone help me in finding the reason for this exception?

The error message Unknown column 'regno' in 'field list' indicates that that column does not exist in the table login.
Either you've typed the column name wrong or, got your table's schema wrong or it simply doesn't exist.

The error is clearly visible. your table named "login" has no column named "regno".

Related

Modify record using Struts2

I have a table with a list of shows, my idea is to have a button that allows modifying each show:
...
<s:iterator value="%{listShow}" var="show">
<tr>
<td><s:property value="showId"></s:property></td>
<td><s:property value="showName"></s:property></td>
<td><s:property value="showDate"></s:property></td>
<td><s:property value="showPrice"></s:property></td>
<td><s:form action="goModify">
<s:submit value="Modify"></s:submit>
<s:hidden name="showId"></s:hidden>
<s:hidden name="showName"></s:hidden>
<s:hidden name="showDate"></s:hidden>
<s:hidden name="showPrice"></s:hidden>
</s:form></td>
</tr>
</s:iterator>
...
The only thing action "goModify" does is redirect to a modify.jsp file where I want to make the data changes:
<s:form action="modifyAction">
<s:textfield label="ID" name="showId" value="%{showId}"></s:textfield>
<s:textfield label="Show Name" name="showName" value="%{showName}></s:textfield>
<s:textfield label="Date" name="showDate" value="%{showDate}></s:textfield>
<s:textfield label="Price" name="showPrice"value="%{showPrice}></s:textfield>
<s:submit value="Modificar"></s:submit>
</s:form>
The problem that the filled fields do not appear to me.
You are only assigning a name to the hidden fields, not a value. You can use the attribute key instead of name. It will automatically generate HTML with the correct name and value.
<s:iterator value="%{listShow}" var="show">
<tr>
<td><s:property value="showId" /></td>
<td><s:property value="showName" /></td>
<td><s:property value="showDate" /></td>
<td><s:property value="showPrice" /></td>
<td>
<s:form action="goModify">
<s:submit value="Modify" />
<s:hidden key="showId" />
<s:hidden key="showName" />
<s:hidden key="showDate" />
<s:hidden key="showPrice" />
</s:form>
</td>
</tr>
</s:iterator>
If the action goModify does not store the parameters in the value stack (e. g. by storing them in attributes), you may have to change the JSP to access the request parameters directly.
<s:form action="modifyAction">
<s:textfield label="ID" name="showId" value="%{#parameters.showId}" />
<s:textfield label="Show Name" name="showName" value="%{#parameters.showName} />
<s:textfield label="Date" name="showDate" value="%{#parameters.showDate} />
<s:textfield label="Price" name="showPrice" value="%{#parameters.showPrice} />
<s:submit value="Modificar"></s:submit>
</s:form>
However, the best solution for the second JSP would also be to use key instead of name and value. But then you have to make sure to have the values on the value stack.

ModelAttribute is null after form

I'm trying to make a small climbing website as a personal project but I struggle to put value inside my modelAttribute.
#RequestMapping("/new_topo")
public String addTopo(Model model){
Topo topo = new Topo();
Sector sector = new Sector();
model.addAttribute("topo", topo);
model.addAttribute("sector", sector);
return "new_topo";
}
As you can see, I add in my model 1 instance of Topo and Sector, where data will be received here :
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Add a Spot</title>
</head>
<body>
<div th:replace="fragment/header :: header"> </div>
<h1 align="center">Add a topo</h1>
<form action="#" th:action="#{/save_topo}" method="post">
<table align="center">
<tr>
<td>cotation</td>
<td> <input type="text" th:field ="${topo.cotation}"> </td>
</tr>
<tr>
<td>sector</td>
<td> <input type="text" th:value ="${sector.name}"> </td>
</tr>
<tr>
<td>spits_amount</td>
<td> <input type="number" th:field ="${topo.spitAmount}"> </td>
</tr>
<tr>
<td colspan="2"><button type="submit">Save</button> </td>
</tr>
</table>
</form>
</body>
</html>
the problem is that when I try to have access to sector's field, it says that "Sector is null" while topo's fields are received perfectly fine. This is how I check the data received :
#RequestMapping(value = "/save_topo", method = RequestMethod.POST)
public String saveTopo(#ModelAttribute("topo") Topo topo, #ModelAttribute("sector") Sector sector){
System.out.println("============================");
System.out.println(topo.getCotation() + " " + topo.getSpitAmount()); // Data 100% received
System.out.println("============================");
System.out.println("NAME IS EQUALS TO : " + sector.getName()); // null, did not receive the input from the form
topo.getSector().add(sector);
sector.setTopo(topo);
topoService.save(topo);
sService.save(sector);
return "topos";
}
note that i'm totally new in the web / back end community and that I might not know 100% of how things works (which I think will be obvious for you).
Thank you for any upcoming help !
EDIT : This might help ?
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Mar 17 09:05:27 GMT 2020
There was an unexpected error (type=Internal Server Error, status=500).
No message available
java.lang.NullPointerException
at com.lufen.Project6.lade.Controller.TopoController.saveTopo(TopoController.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter.doFilterInternal(DefaultLogoutPageGeneratingFilter.java:52)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:216)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
To store the values taken from input text fields in object fields we have to use th:object="${object_name}" in thymeleaf.
But here there is a need to store the input values in two different objects.
We can create a class that contains fields of type both Sector and Topo.
public class SectorAndTopo{
Sector sector = new Sector();
Topo topo = new Topo();
}
Add the object of this class as attribute to model
#RequestMapping("/new_topo")
public String addTopo(Model model){
SectorAndTopo sectorAndTopo = new SectorAndTopo();
model.addAttribute("sectorAndTopo", sectorAndTopo);
return "new_topo";
}
<form action="#" th:action="#{/save_topo}" th:object="${sectorAndTopo}" method="post">
<input type="text" th:field ="*{topo.cotation}">
<input type="text" th:field ="*{sector.name}">
<input type="number" th:field ="*{topo.spitAmount}">
<button type="submit">Save</button>
Please try this (note the name attribute, which should equal to the bean field names):
<input type="text" th:value="${sector.name}" name="name">
If it doesn`t work, change the rest like this too:
<input type="text" th:value="${topo.cotation}" name="cotation"> </td>
<input type="number" th:value="${topo.spitAmount}" name="spitAmount"> </td>
The only difference I see between the one which works and which don't is attribute field and value.
Change
th:value ="${sector.name}"
To
th:field ="${sector.name}"

Getting java.lang.NumberFormatException: For input string: "aNumber"

I want to print a list of Users on JSP. This list getting captured in controller method correctly but it is not passed on to the JSP page.
Controller Method Code -
#PostMapping("/list")
public String listCandidates(#RequestParam("list") String roType, Model theModel) {
if(roType.equalsIgnoreCase("qualZRO1"))
{
List qList = adgService.getQualCandListZRO1();
theModel.addAttribute("candlist", qList);
return "adgSummary";
}
}
JSP Page - I want to display the below information about candidates in a table form in JSP page. Refer below stacktrace which shows that there is NumberFormatException error with "aNumber".
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix= "fmt" %>
<!DOCTYPE html>
<html><head>
<title></title>
<!-- reference our style sheet -->
<link type="text/css"
rel="stylesheet"
href="${pageContext.request.contextPath}/resources/css/style.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div style="text-align:center">
<h2>SRS</h2>
</div>
</div>
</div>
<div>
<!-- viewing the details -->
Z1 Qualified Candidates: <c:out value="${qualCandZ1}"/>
Z1 Selected Candidates: <c:out value="${selCandZ1}"/>
I1 Qualified Candidates: <c:out value="${qualCandI1}"/>
I1 Selected Candidates: <c:out value="${selCandI1}"/>
</div>
<div id="container">
<div id="content">
<!-- add a search box -->
<form:form name="list" action="list" method="POST">
<input type="hidden" name="list" />
<input type="submit" value="qualZRO1" name="dayOne" class="add-button" onclick="{document.list.list.value=this.value;}" />
<input type="submit" value="selZRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" />
<input type="submit" value="qualIRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" />
<input type="submit" value="selIRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" />
</form:form>
<table><tr>
<th>A No</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>RO</th>
<th>AType</th>
<th>Score</th>
<th>Result</th>
<th>Selected</th>
</tr>
<!-- loop over and print our candidates-->
<c:forEach var="tempCustomer" items="${candlist}">
<tr>
<td> ${tempCustomer.aNumber} </td>
<td> ${tempCustomer.firstName} </td>
<td> ${tempCustomer.middleName} </td>
<td> ${tempCustomer.lastName} </td>
<td> ${tempCustomer.ro} </td>
<td> ${tempCustomer.aType} </td>
<td> ${tempCustomer.score} </td>
<td> ${tempCustomer.result} </td>
<td> ${tempCustomer.selected} </td>
</tr></c:forEach></table></div></div></body></html>
Stacktrace from Console window which shows NumberFormatException error -
Apr 25, 2018 9:42:11 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet [jsp] threw exception
java.lang.NumberFormatException: For input string: "aNumber"
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:144)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:61)
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:702)
at org.apache.jsp.WEB_002dINF.view.adgSummary_jsp._jspx_meth_c_005fforEach_005f0(adgSummary_jsp.java:426)
at org.apache.jsp.WEB_002dINF.view.adgSummary_jsp._jspService(adgSummary_jsp.java:214)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
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)
Apr 25, 2018 9:42:11 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/SRS-ADGDELHI] threw exception [An exception occurred processing [WEB-INF/view/adgSummary.jsp] at line [71]
68: <c:forEach var="tempCustomer" items="${candlist}">
69:
70: <tr>
71: <td> ${tempCustomer.aNumber} </td>
72: <td> ${tempCustomer.firstName} </td>
73: <td> ${tempCustomer.middleName} </td>
74: <td> ${tempCustomer.lastName} </td>
Try changing the List qList to List<your_class> qlist.
Follow this link for additional info : ${employee.id} from List in JSP throws java.lang.NumberFormatException: For input string: "id"
You can change the List qlist to generic.
You can change your code like List<classname> qList = adgService.getQualCandListZRO1();
insted of List qList = adgService.getQualCandListZRO1();

How Can i Update a Table (not datatable) with a Primefaces CommandButton

<h:form id="tableForm">
<table id="myTable">
<tr>
<th>HeaderOne</th>
<th>HeaderTwo</th>
<th>HeaderThree</th>
</tr>
<ui:repeat value="#{myBean.List}" var="row">
<tr class="myRows">
<td><input type="text" value="#{row.fieldOne} required="required" /></td>
<td><input type="text" value="#{row.fieldTwo} /></td>
<td><input type="text" value="#{row.fieldThree} /></td>
</tr>
</ui:repeat>
</table>
<p:commandButton id="myButton" value="Load" action="#{myBean.load}" process="#this" update="myTable" />
</h:form>
i want to load some stuff into my inputFields from my bean, but have one field that is required when i press save. So i have to set process to #this.
Afterwards i want my table to be updated. But i doesn't work.
What am i doing wrong?
try updating the form instead
<p:commandButton ... action="#{myBean.load}" process="#this" update="tableForm" />
since the table is not a jsf element but "pure" html, you can't use it's id in jsf elements
Schäbo answer is right (+1) but Primefaces also provides a p:fragment component so you may update only the region you want to:
<p:fragment id="myFragmentReloaded">
<table>
...
</table>
</p:fragment>
and then
<p:commandButton ... action="#{myBean.load}" process="#this" update="myFragmentReloaded" />

Using Omnifaces EL functions in composite component with Mojarra 2.2.5

After upgrading to JSF Mojarra 2.2.5, i get the following exception when using Omnifaces's el function formatNumber. This only occurs within a composite component. Normal Facelet is working fine.
javax.el.ELException: Function 'of:formatNumber' not found
this is my composite component:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:of="http://omnifaces.org/functions">
<cc:interface>
<cc:attribute name="cart" required="true" type="org.ead.eeb.order.ShoppingCart" />
<cc:attribute name="allowCouponRemove" required="true" type="java.lang.Boolean" />
<cc:attribute name="removeCouponBean" type="java.lang.Object" />
<cc:attribute name="removeCouponAction" type="java.lang.String" />
<cc:attribute name="removeCouponProperty" type="java.lang.String" />
</cc:interface>
<cc:implementation>
<h4>Übersicht</h4>
<table class="table">
<tbody>
<c:forEach items="#{cc.attrs.cart.items}" var="item">
<tr>
<td><abbr title="#{item.description}">#{item.name}</abbr></td>
<td class="text-right">#{of:formatNumber(item.totalAmount, '#0.00')} €</td>
</tr>
</c:forEach>
<tr>
<td>Mehrwertsteuer (#{cc.attrs.cart.taxRatePercentage} %)</td>
<td class="text-right">#{of:formatNumber(cc.attrs.cart.totalTax, '#0.00')} €</td>
</tr>
</tbody>
<tfoot>
<tr class="active">
<td><strong>Gesamtbetrag</strong></td>
<td class="text-right"><strong>#{of:formatNumber(cc.attrs.cart.totalOrderAmount, '#0.00')} €</strong></td>
</tr>
</tfoot>
</table>
...
</cc:implementation>
thanks in advance for your help :)
Edit:
the problem occurs, if i use the value from cc.attrs.*. If I use the value directly as an attribute, everthing is working well. Any ideas?
Edit2:
A workaround is possible by the following code
<c:set var="test" value="#{cc.attrs.value}" />
#{of:formatNumber(test, '#0.00')}
but that's pretty ugly. I can't find my mistake.
The issue i created was marked as Wont't Fix, since there is a workaround:
Replacing all convenient inline el calls of type #{foo} with <h:outputText value="#{foo}"/>.
https://java.net/jira/browse/JAVASERVERFACES-3469
Very inconvenient and cumbersome. Many regressions from 2.2.4 -> 2.2.5.