Theeranit Pongtongmuang

Greenhorn
+ Follow
since May 17, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Theeranit Pongtongmuang

Thanks for your reply
14 years ago
Hello everyone

I try to create pattern for user to create new password

pasword 's length must be equal or greater than 8
and the charactor can be a-z A-Z 0-9 and special charactor !@#$%^*()_+-?.,<>}{[]}
each charactor can occure equal or greater than 0


Thank you in advance
14 years ago
I've tried to send image to server via mobile and web service wsdl and got problem with base64binary type

For wsdl




When I put this wsdl in J2ME web service client and got

getbase64_func(byte[] image) method for sending image to server

So I've tried this code for MIDlet



and the result I got is the message server doesn 't encode data
I don't know why java parse base64binary to byte[] for getbase64_func method instead of string.
and I don't know the error that might happen converting Stringbase64 to byte[]

Please could you help me to solve this problem.

Thanks
14 years ago
Hello everyone I try to find class for converting converting bytearray to base64binary implementation of MIME's Base64 encoding and decoding conversions. .

Those I found only String to base64 or base64 to string. I try to use them by converting String to byteArray and create new String from byte array.
However it does't work on runtime.

Please could you help me find class for converting between byteArray and base64binary Implementation of MIME's Base64 encoding and decoding conversions.
and class must be light weght because I nee to work with J2ME.

Thanks,
14 years ago
Thank you for your reply.

However, I want the page refresh after download zip file completely.

So, I try to return view(mapping, exportForm, request, response);
to get the page refresh and got this problem.

Please give me some suggestion.
14 years ago
I got java.lang.IllegalStateException and don't know how to solve this problem.

public ActionForward exportToBtmu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {


byte[] buf = new byte[1024];

try {
// Create the ZIP file


response.setContentType("application/zip");
response.setHeader("Content-Disposition","attachment;filename=export.zip;");


ZipOutputStream out = new ZipOutputStream(response.getOutputStream());

// Compress the files

FileInputStream in = new FileInputStream(txt1.txt);

// Add ZIP entry to output stream. only file Name not full path
out.putNextEntry(new ZipEntry(txt1.txt));

// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

// Complete the entry
out.closeEntry();
in.close();

// delete file after complete add to zip
fileToZip.delete();

out.flush();
// Complete the ZIP file
out.close();

} catch (IOException e) {
e.printStackTrace();

}



return mapping.findForward(FORWARD_view);

}


and this is exception message that I got



java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:173)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:889)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
at org.apache.jsp.pages.template_jsp._jspx_meth_tiles_005finsert_005f0(template_jsp.java:251)
at org.apache.jsp.pages.template_jsp._jspx_meth_logic_005fnotEmpty_005f0(template_jsp.java:223)
at org.apache.jsp.pages.template_jsp._jspx_meth_html_005fhtml_005f0(template_jsp.java:158)
at org.apache.jsp.pages.template_jsp._jspService(template_jsp.java:84)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.struts.action.RequestProcessor.doInclude(RequestProcessor.java:1116)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:260)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Aug 20, 2009 6:33:06 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:173)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:889)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
at org.apache.jsp.pages.template_jsp._jspx_meth_tiles_005finsert_005f0(template_jsp.java:251)
at org.apache.jsp.pages.template_jsp._jspx_meth_logic_005fnotEmpty_005f0(template_jsp.java:223)
at org.apache.jsp.pages.template_jsp._jspx_meth_html_005fhtml_005f0(template_jsp.java:158)
at org.apache.jsp.pages.template_jsp._jspService(template_jsp.java:84)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.struts.action.RequestProcessor.doInclude(RequestProcessor.java:1116)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:260)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

I 'm waiting for your good suggestion.

Amm


14 years ago
Thank jtanzy for your helping.

However, I can solve this problem. I think method putNextEntry(new ZipEntry()) that accept ZipEntry and for ZipEntry constructor.
I refer the file only file name. No need for full path. Then I's done.

For example

out.putNextEntry(new ZipEntry(text1.txt));
14 years ago
Hello everyone

I am looking for a light weight base64 encoder and decoder class that very small size because I need to use it with mobile application.
Some class that I found don't work and quite large.

Please could you give me base64 class or give link where to download it.

Thank you very much.
14 years ago
Hello everyone

I've tried to create zip file from multiple text file.

This is code snippet.

// These are the files to include in the ZIP file
String[] filenames = new String[]{"c:\\temp\\text1.txt", "c:\\temp\\text2.txt"};

// Create a buffer for reading the files
byte[] buf = new byte[1024];

try {
// Create the ZIP file
String outFilename = "c:\\temp\\zipOut.zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));

// Compress the files
for (int i=0; i<filenames.length; i++) {
FileInputStream in = new FileInputStream(filenames[i]);

// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(filenames[i].replace(File.separatorChar,'/')));

// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

// Complete the entry
out.closeEntry();
in.close();
}

// Complete the ZIP file
out.close();
} catch (IOException e) {
e.printStackTrace();
}

There is zip file after I 've run this code. However, there is nothing in zip file no text files that I expected.

Please could you help to solve this problem. It's take me an hour since I tried to do it myself.

Thanks,
14 years ago
Thank you very much for your suggestion.

I get an idea to solve this problem.
14 years ago
Hello everyone,

I'm very new for Java I/0.

I want to convert Image object to byte array (byte[])
This is my code for creating Image.


Image myImage =null;
try {
myImage = Image.createImage("/myImage.png");
} catch (IOException ex) {
ex.printStackTrace();
}

How can I convert "myImage" to byte[] with Java I/0

Please could you give me a good suggestion and code snippet.

Thanks a lot.
14 years ago
Hello every, I use Struts for framework and try to read excel file that stored in project folder with POI API.
However, I don't know where we should put the original file in the project.
When build project, the file will be included to deployed folder automatically.
Actually, I've put it in web content folder or WEB-INF, the first time of building, the file was included to deployed folder.
When I deleted the file in deployed folder and started building again, the file was not include to deployed folder.

Please could you give me some suggestion.
Thank you verymuch, Ulf Dittmer.
Your reply is useful information.
Ulf Dittmer
Thank you very much Ulf Dittmer.
I put class file in WEB-INF and file created.

However, there something goes wrong. The file was created and pasted in eclipse program folder.
How can I set this if I want file created in web content folder.

Please give me some suggestion.

Thanks,