Syntax error: Invalid table specification - java

While retrieving data from Sage 50 i get this error. I googled it but I can't find anything. Logically I thought that my table names where wrong in my SQL query but I think they are not. I can't see the database because it's an external program.
The error is:
Syntax error: Invalid table specification
Has anyone encountered the same problem?When I run following code:
String query = "SELECT TRAN_NUMBER,PAID_FLAG,AUDIT_USAGE.DATE, AUDIT_USAGE.DELETED_FLAG "
+ "FROM AUDIT_SPLIT FULL "
+ "OUTER JOIN AUDIT_USAGE ON AUDIT_USAGE.REFERENCE = AUDIT_SPLIT.INV_REF "
+ "AND AUDIT_USAGE.SPLIT_NUMBER = AUDIT_SPLIT.TRAN_NUMBER "
+ "WHERE NOMINAL_CODE = 2401 and AUDIT_SPLIT.DETAILS NOT LIKE 'Deleted%'";
I get following Exception:
java.sql.SQLException: Syntax error: Invalid table specification
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
at org.apache.jsp.run_005fgovlevy_jsp._jspService(run_005fgovlevy_jsp.java:90)
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 net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
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(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

At least in ANSI SQL DATE is a reserved word. Double quote it:
SELECT TRAN_NUMBER, PAID_FLAG, AUDIT_USAGE."DATE" ...

Couldn't find a query that works on multiple tables, so I queried the data in each table and saved it to my local server and the used the query above and it worked fine.

Related

Why am I getting NullPointerException in liferay?

I am getting a NullPointerException on the following line:
originalStrutsPortletAction.processAction(
originalStrutsPortletAction, portletConfig, actionRequest,
actionResponse);
I am printing all the values:
System.out.println(originalStrutsPortletAction);
System.out.println(portletConfig);
System.out.println(actionRequest);
System.out.println(actionResponse);
Output:
com.liferay.portal.struts.StrutsPortletActionAdapter#2f20c4be
com.liferay.portlet.PortletConfigImpl#5f4268dd
com.liferay.portlet.ActionRequestImpl#1054ae1e
com.liferay.portlet.ActionResponseImpl#27733bf2
So why am I getting NullPointerException? Please help.Thanks in advance.
The full stack trace is as follows:-
java.lang.NullPointerException
at com.liferay.portlet.login.action.LoginAction.login(LoginAction.java:196)
at com.liferay.portlet.login.action.LoginAction.processAction(LoginAction.java:93)
at com.liferay.portal.struts.StrutsPortletActionAdapter.processAction(StrutsPortletActionAdapter.java:60)
at com.liferay.portal.kernel.struts.BaseStrutsPortletAction.processAction(BaseStrutsPortletAction.java:44)
at com.abhishek.ExampleLoginAction.check(ExampleLoginAction.java:185)
at org.apache.jsp.jsp.otpCheck_jsp._jspService(otpCheck_jsp.java:71)
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 com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at sun.reflect.GeneratedMethodAccessor503.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
at com.sun.proxy.$Proxy660.doFilter(Unknown Source)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.PortalClassLoaderFilter.doFilter(PortalClassLoaderFilter.java:74)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
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:99)
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:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Simple answer: You don't get a NullpointerException at that location- at least not according to the stacktrace you post. Liferay's LoginAction does not have an originalStrutsAction. In case you're using 6.2 GA5, this is the code that throws the NullpointerException. Why? That's not what you asked.
Or, to phrase it differently: You're getting a NullpointerException because you dereference a Nullpointer. You'll just need to identify where you actually get it. The stacktrace helps. Who knows what your ExampleLoginAction does before it calls the line that you're posting...

FileNotFoundException Access Denied

I'm having a little issue with FileNotFoundException.
java.io.FileNotFoundException: C:\Program Files (x86)\Apache Software
Foundation\Tomcat 7.0\webapps\folder\folder\folder (Access is denied) at
java.io.FileOutputStream.open(Native Method) at
java.io.FileOutputStream.(Unknown Source) at
java.io.FileOutputStream.(Unknown Source) at
org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:416)
at org.apache.jsp.control_jsp._jspService(control_jsp.java:2715) 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
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
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:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The file is uploaded from a web form. I don't think there is a reason for the code above this.
Code:
String itemName = item.getName();
if (itemName.indexOf("\\") != -1) {
int slash = itemName.lastIndexOf("\\");
if (slash != -1) {
itemName = itemName.substring(slash + 1);
}
// I think Windows doesn't like /'s either
int slash2 = itemName.lastIndexOf("/");
if (slash2 != -1) {
itemName = itemName.substring(slash2 + 1);
}
// In case the name is C:foo.txt
int slash3 = itemName.lastIndexOf(":");
if (slash3 != -1) {
itemName = itemName.substring(slash3 + 1);
}
}
File savedFile = new File(config.getServletContext().getRealPath("/") + "filing/" + itemName);
item.write(savedFile);
This happens for more folders in my web app.
I searched the internet for solutions but the only thing I found about this specific error is that:
The folder is inaccessible like when it's write protected (Read Only) but my folders have access to all except Special Permissions and Full Control.
By the way all my folders are created dynamically in the code.
P.S The code is not mine, I'm just finding these errors in my webapp stderr everyday, it doesn't seem to create a problem but I would like to solve it.
Has anyone experienced the same problem or can help out?
I know it's not really serious question but it never hurts to ask.
Thanks in advance.

how to retrieve character values from table in mysql?

I insert data in mysql database like as-
create table details(loginid varchar(55),interser1 char,interser2 char,interser3 char);
insert into details values("1",'y','n','y');
when i am retriving in jsp-
ResultSet rs=st.executeQuery("select * from interest where loginid='1'");
String interest1=rs.getString(2);//but at index-2 value is character.
String interest2=rs.getString(3);
String interest3=rs.getString(4);
this is giving me Error-
SEVERE: Servlet.service() for servlet [jsp] in context with path [/more_value_in_param] threw exception [An exception occurred processing JSP page /display.jsp at line 19
16: Connection con=CommonUtil.getConnection();
17: Statement st=con.createStatement();
18: ResultSet rs=st.executeQuery("select * from interest where loginid='1'");
19: String interest1=rs.getString(2);
20: String interest2=rs.getString(3);
21: String interest3=rs.getString(4);
22: ResultSet rs1=st.executeQuery("select * from details where loginid='1'");
Stacktrace:] with root cause
java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:841)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5650)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5570)
at org.apache.jsp.display_jsp._jspService(display_jsp.java:84)
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:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
how to retrieve character values from table in mysql?
I think the problem is that you need to call rs.next() to ensure there is result first before retrieving any result. So you will need to have:
ResultSet rs=st.executeQuery("select * from interest where loginid='1'");
while (rs.next()) {
String interest1=rs.getString(2);
String interest2=rs.getString(3);
String interest3=rs.getString(4);
}
For you question, you can get the character by calling rs.getString(2).charAt(0). By the way, if possible, please try to have this logic in your controller or action, not in JSP.

Check '!= null" not working

I have facing "NullPointerException" in code. We have already check not null, but it's not working for us in the below screenshot. I already check folderInfoData.getSelectedInfoRole() != null but its enter to the if statement. It's private SelectOption<String> selectedInfoRole; type.
How to fixed this issue?
18:26:22,589 246302 ERROR [zk.ui.impl.UiEngineImpl ] -
java.lang.NullPointerException
at com.csdcsystems.amanda.web.viewmodel.FolderProcessInfoViewModel.saveInfoDetails(FolderProcessInfoViewModel.java:234)
at com.csdcsystems.amanda.web.viewmodel.FolderProcessInfoViewModel.saveProcessInfo(FolderProcessInfoViewModel.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:113)
at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1748)
at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1509)
at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:108)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1378)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1330)
at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2746)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2717)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2658)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1765)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1550)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1260)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:603)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
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 com.csdcsystems.servlets.AmandaSessionFilter.doFilter(AmandaSessionFilter.java:46)
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:99)
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:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
18:26:22,597 246302 INFO [csdcsystems.amanda.web.AmandaPerformanceMeter ] - Command name:saveProcessInfo
Here is Screenshot:
My guess is that you have a NullPointerException because either folderInfoData.getFolderprocessInforecord() or folderInfoData.getSelectedInfoRole().getValue() returns null and then you call getInfoValue on it.
To help debugging similar issues, try to keep lines simpler:
infoRole = folderInfoData.getSelectedoInfoRole().getValue();
infoRecord = folderInfoData.getFolderprocessInforecord().getValue();
if (!infoRole.equals(infoRecord) {
...
}
This would report a NullPointerException on the second line and would save you some time debugging.

Error in sending Vector from one Action to another through jsp

I am using Struts 1. I need to send Vector of Objects from one Action to another throuh jsp.
In Action1:
Defined Vector Vector<UserObject> allEligibleUserList = new Vector<UserObject>();
and after adding objects request.setAttribute("elligible", allEligibleUserList);
In jsp:
<html:hidden property="userVector" value="${elligible}" />
In Form:
private Vector<UserObject> userVector;
public Vector<UserObject> getUserVector() {
return userVector;
}
public void setUserVector(Vector<UserObject> userVector) {
this.userVector = userVector;
}
In Action2:
Vector<UserObject> elligibleUserVector = catalogForm.getUserVector();
But I am getting the following error:
SEVERE: Servlet.service() for servlet [action] in context with path [/MetalWeb] threw exception [BeanUtils.populate] with root cause
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
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 com.mj.metal.filters.AutoLoggingFilter.doFilter(AutoLoggingFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.mj.metal.filters.AutoXSSFilter.doFilter(AutoXSSFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.mj.metal.filters.CSRFGuardFilter.doFilter(CSRFGuardFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
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:409)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
What am I doing wrong and how do I fix this?
Request attributes accept only String or String arrays.
So to transfer data from one action to another through a jsp, you should set it as a session attribute like this:
request.getSession().setAttribute("elligible", allEligibleUserList);
and in the next action class get the attribute and delete it like this:
Vector<UserObject> elligibleUserVector = (Vector<UserObject>) request.getSession().getAttribute("elligible");
request.getSession().removeAttribute("elligible");

Categories

Resources