my problem is from my portlet application i get data from database, the JSP show as following table:
Order id | Name | IC |Contact No.
1000 |wang |g100|0122326182
1000 |wang |g100|0122326182
1000 |wang |g100|0122326182
1000 |wang |g100|0122326182
i need a button to export the data to Excel file.
i am already read all the related post in this forums, from http://www-128.ibm.com/developerworks/forums/thread.jspa?messageID=13987685&#13987685
i got some ideas to using a servelet to process the data,when i try to depoly it into my code,it not working, from the JSP page i can not call the serverlet using the code :
input type="button" value="Export Into Excel" onclick= "location.href='
is there anybody know how to solve the problem? and are there need some confige inside the portlet.xml or web.xml?
If possible can you show me some code for how to access it, thanks!
Online waiting your reply!!
IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0
The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/ExportExcelServlet")
rd.include(request,response);
but from the JSP page can not call the servlet..
the following coding is my servlet, when inside the servlet,
* response.setContentType("application/vnd.ms-excel");*
this line hit error....
public class ExportExcelServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// TODO Auto-generated method stub
String filename = "WebPortInSummaryReport";
String data = "";
data=getData(request);
response.reset();
* response.setContentType("application/vnd.ms-excel");*
response.setHeader("Content-Disposition", "attachment;filename=Device.xls");
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
ServletOutputStream op;
try
{
op = response.getOutputStream();
op.write(data.getBytes());
op.close();
}
catch (IOException e)
{
//TODO Auto-generated catch block
e.printStackTrace();
}
}
the error message as follow:
6/26/08 19:33:00:279 SGT 00000052 ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet ExportExcelServlet. Exception thrown : java.lang.IllegalArgumentException: application/vnd.ms-excel
at org.apache.pluto.core.impl.RenderResponseImpl.setContentType(RenderResponseImpl.java:152)
at javax.servlet.ServletResponseWrapper.setContentType(ServletResponseWrapper.java(Compiled Code))
at webmnpportinsummaryreport.ExportExcelServlet.doGet(ExportExcelServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
....
6/26/08 19:33:00:544 SGT 00000052 ServletWrappe E SRVE0014E: Uncaught service() exception root cause ExportExcelServlet: application/vnd.ms-excel
6/26/08 19:33:00:778 SGT 00000052 LocalTranCoor E WLTC0017E: Resources rolled back due to setRollbackOnly() being called.
6/26/08 19:33:00:841 SGT 00000052 ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet WebMNPPortInSummaryReport. Exception thrown : javax.servlet.ServletException: application/vnd.ms-excel
at com.ibm.wps.pe.pc.std.invoker.impl.PortletServlet.convertException(PortletServlet.java:218)
at com.ibm.wps.pe.pc.std.invoker.impl.PortletServlet.dispatch(PortletServlet.java:196)
at com.ibm.wps.pe.pc.std.invoker.impl.PortletServlet.doPost(PortletServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
.......
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Caused by: java.lang.IllegalArgumentException: application/vnd.ms-excel
........
6/26/08 19:33:00:872 SGT 00000052 ServletWrappe E SRVE0014E: Uncaught service() exception root cause WebMNPPortInSummaryReport: java.lang.IllegalArgumentException: application/vnd.ms-excel
at org.apache.pluto.core.impl.RenderResponseImpl.setContentType(RenderResponseImpl.java:152)
at javax.servlet.ServletResponseWrapper.setContentType(ServletResponseWrapper.java(Compiled Code))
at webmnpportinsummaryreport.ExportExcelServlet.doGet(ExportExcelServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
..........
i am not quite understand what should i do for that? is that mean when i call the pop up widow then i set the content type and do the processing to save data to excel file?
can you give me a piece of code to help me to understand it.. very appreciate for your reply.. thanks!