SerializationException ... Help!

2012-04-23 Thread Leonardo Terrão
0.1:/insweb/
  Content-Type: text/x-gwt-rpc; charset=UTF-8
  X-GWT-Permutation: HostedMode
  Referer: http://127.0.0.1:/INSWEB.html?gwt.codesvr=127.0.0.1:9997
   Response headers
  Content-Type: text/plain


Thank you!
Leonardo Terrão.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: capture image from mysql

2012-04-03 Thread Leonardo Terrão
Oh how wonderful!

began to work without any changes! I believe it was some cache or even
eclipse the browser that was forcing the error!

Thanks guys!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



capture image from mysql

2012-04-02 Thread Leonardo Terrão
Hello people!

I'm trying to retrieve an image of the mysql database, I am trying to
restore the image using servlet but I'm not very skilled with it ...
I code returns the following error:

java.lang.IllegalStateException: Committed
at org.mortbay.jetty.Response.resetBuffer(Response.java:995)
at org.mortbay.jetty.Response.reset(Response.java:938)
at
br.com.google.server.FileUploadServlet.doGet(FileUploadServlet.java:
52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
362)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
49)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
[WARN] 405 - GET /upload (127.0.0.1) 1462 bytes
   Request headers
  Host: 127.0.0.1:
  Connection: keep-alive
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/
535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11
  Accept: */*
  Referer: 
http://127.0.0.1:/ProjetoImagem.html?gwt.codesvr=127.0.0.1:9997
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Cookie: JSESSIONID=uibpkj9tbmhv
   Response headers
  Content-Type: text/html; charset=iso-8859-1
  Content-Length: 1462


I will also post my class on the server side:

public class FileUploadServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
super.doGet(req, resp);

 Connection conn = null;
 Statement st = null;
try
{
Class.forName(AbstractDAO.DRIVER);
conn = DriverManager.getConnection(AbstractDAO.URL,
AbstractDAO.USUBD, AbstractDAO.SENHABD);

st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT IMAGEM FROM 
tbl_imagem where
CD_IMAGEM = 2");

String imgLen = "";

while(rs.next()){
imgLen = rs.getString(1);
System.out.println(imgLen.length());
int len = imgLen.length();
byte [] rb = new byte[len];
InputStream readImg = rs.getBinaryStream(1);
int index = readImg.read(rb, 0, len);
System.out.println("index 
" + index);
resp.reset();
resp.setContentType("image/jpg");
resp.getOutputStream().write(rb, 0, len);
resp.getOutputStream().flush();
}

st.close();
resp.getOutputStream().close();

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

to retrieve the client-side image I made as follows:

Image image = new Image(GWT.getHostPageBaseURL() + "upload");
rootPanel.add(image, 289, 138);
image.setSize("200px", "200px");


Anyone know any solution for me to solve my problem or any tips that I
may be using?

Thank you!
Leonardo Terrão

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send e

Re: Upload File

2012-03-05 Thread Leonardo Terrão
t;                         // if the client form disappears before we've
> >> read the
> >>                         // entire stream.
> >>                         int bytes;
> >>                         byte buf[] = new byte[32768];
> >>                         while ((bytes = stream.read(buf)) > 0)
> >>                             out.write(buf, 0, bytes);
> >>                     }
> >>                     catch (Throwable t)
> >>                     {
> >>                         p_response.sendError(SC_**INTERNAL_SERVER_ERROR,
> >>                                 t.getClass().getName() + " " +
> >> t.getMessage());
> >>                         t.printStackTrace();
> >>                     }
> >>                     finally
> >>                     {
> >>                         out.close();
> >>                         stream.close();
> >>                     }
> >>                     ClientFileSystemBridge.put(id, filename, f);
> >>                     response.append(name).append(' ').
> >>                              append(f.length()).append(' ').
> >>                              append(filename).append('\n')**;
> >>                 }
> >>             }
> >>             String message = response.toString();
> >>             p_response.reset();
> >>             p_response.setContentType("**text/plain");
> >>             p_response.setContentLength(**message.length());
> >>             Writer writer = p_response.getWriter();
> >>             writer.append(message);
> >>             writer.flush();
> >>         }
> >> //        catch (FileUploadException e)
> >> //        {
> >> //            p_response.sendError(SC_**INTERNAL_SERVER_ERROR,
> >> e.getMessage());
> >> //            e.printStackTrace();
> >> //        }
> >>         catch (Throwable e)
> >>         {
> >>             p_response.sendError(SC_**INTERNAL_SERVER_ERROR,
> >> e.getMessage());
> >>             e.printStackTrace();
> >>         }
> >>     }
>
> >> And a helper function for reporting progress:
>
> >> import org.apache.commons.fileupload.**ProgressListener;
>
> >> public class FileUploadProgress implements ProgressListener
> >> {
> >>     private volatile long m_bytesRead;
> >>     private volatile long m_contentLength;
> >>     private volatile int m_item;
>
> >>     public FileUploadProgress()
> >>     {
> >>         super();
> >>     }
>
> >>     public void update(long p_bytesRead, long p_contentLength, int
> >> p_item)
> >>     {
> >>         m_bytesRead = p_bytesRead;
> >>         m_contentLength = p_contentLength;
> >>         m_item = p_item;
> >>     }
>
> >>     public long getBytesRead()
> >>     {
> >>         return m_bytesRead;
> >>     }
>
> >>     public long getContentLength()
> >>     {
> >>         return m_contentLength;
> >>     }
>
> >>     public int getItem()
> >>     {
> >>         return m_item;
> >>     }
> >> }
>
> >> On Mar 2, 5:26 am, Leonardo Terrão  wrote:
> >> > Hello everybody!
>
> >> > Following are some examples found right here in the discussion group
> >> > took two classes below.
>
> >> > In my class I have ArquivoUpload umTextBox a form with a ListBox and a
> >> > FileUpload. In class FileUploadServlet're getting only the data from
> >> > the FileUpload. Could someone help me also take the data from the
> >> > TextBox?
> >> > In debug mode I see everything that is in the form of the request but
> >> > I can not extract the values​​.
>
> >> > public class ArquivoUpload implements EntryPoint {
>
> >> >         public static final String UPLOAD_ACTION_URL =
> >> GWT.getModuleBaseURL()
> >> > + "upload";
>
> >> >         @Override
> >> >         public void onModuleLoad() {
>
> >> >                 // Cria um FormPanel e apontá-lo para um serviço.
> >> >                 final FormPanel form = new FormPanel();
> >> >                 form.setAction(UPLOAD_ACTION_**URL);
>
> >> >                 // Porque nós vamos adicionar um widget FileUpload,
> >> vamos precisar
> >

Upload File

2012-03-02 Thread Leonardo Terrão
Hello everybody!

Following are some examples found right here in the discussion group
took two classes below.

In my class I have ArquivoUpload umTextBox a form with a ListBox and a
FileUpload. In class FileUploadServlet're getting only the data from
the FileUpload. Could someone help me also take the data from the
TextBox?
In debug mode I see everything that is in the form of the request but
I can not extract the values​​.

public class ArquivoUpload implements EntryPoint {

public static final String UPLOAD_ACTION_URL = GWT.getModuleBaseURL()
+ "upload";

@Override
public void onModuleLoad() {

// Cria um FormPanel e apontá-lo para um serviço.
final FormPanel form = new FormPanel();
form.setAction(UPLOAD_ACTION_URL);

// Porque nós vamos adicionar um widget FileUpload, vamos 
precisar
para
// definir o
// Form usar o método POST, e codificação MIME multipart.
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);

// Cria um painel para conter todos os elementos do formulário.
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);

// Criar um TextBox, dando-lhe um nome para que ele será 
submetido.
final TextBox tb = new TextBox();
tb.setName("TextBoxFormElement");
panel.add(tb);

// Criar um ListBox, dando-lhe um nome e alguns valores que 
devem
ser
// associados
// Com suas opções.
ListBox lb = new ListBox();
lb.setName("listBoxFormElement");
lb.addItem("foo", "fooValue");
lb.addItem("bar", "barValue");
lb.addItem("baz", "bazValue");
panel.add(lb);

// Criar um widget FileUpload.
final FileUpload upload = new FileUpload();
upload.setName("uploadFormElement");
panel.add(upload);

panel.add(new UploadForm());

// Adicionar um botão 'Enviar'.
panel.add(new Button("Submit", new ClickHandler() {
public void onClick(ClickEvent event) {
form.submit();
}
}));

//Adicionar um manipulador de eventos para o formulário.
form.addSubmitHandler(new FormPanel.SubmitHandler() {

@Override
public void onSubmit(SubmitEvent event) {

if (upload.getFilename().equals("")) {
event.cancel();
return;
}

//Este evento é disparado pouco antes do 
formulário é submetido.
//Podemos aproveitar esta oportunidade para 
realizar a validação.
String filename= upload.getFilename();
int index = filename.lastIndexOf(".");
String ext = filename.substring(index + 1);
if (!(ext.equals("gif") || ext.equals("jpg") || 
ext.equals("GIF")
|| ext.equals("JPG"))){
Window.alert("Extensão de arquivo 
inválida. Por favor adicione
apenas arquivos com extensões .jpg ou .gif.");
event.cancel();
}
}
});

form.addSubmitCompleteHandler(new 
FormPanel.SubmitCompleteHandler()
{
@Override
public void onSubmitComplete(SubmitCompleteEvent event) 
{
///Quando o envio do formulário é concluída com 
êxito,
//este evento é acionado. Assumindo que o 
serviço retornou
//uma resposta do tipo text / html, podemos 
obter o texto
resultado aqui
//(consulte a documentação FormPanel para mais 
explicações).
Window.alert(event.getResults());
System.out.println(event.getResults());
}
});
RootPanel rootPanel = RootPanel.get();
rootPanel.add(form);
}
}



public class FileUploadServlet extends HttpServlet {

private static final String UPLOAD_DIRECTORIY = "C:\\uploaded\\";

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse
resp)
throws ServletException, IOException {
super.doGet(req, resp);
}

@SuppressWarnings("unchecked")