Ned Racine schrieb:
> I'm not to familiar with the "fitting content type", you maybe show me
> a clip of sample code?

public class MyServlet extends HttpServlet{
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
              throws ServletException, java.io.IOException{
    byte[] data = getTheFileData(req);
    resp.setContentType("image/jpeg");
    resp.getOutputStream().write(data);
  }
}

getTheFileData(req) is an imaginary method that is getting the
image-data as byte-array. This can be done by reading it from
a created file (that is deleted after that) or you create the
image dynamically, etc.

I pass req to that method, because in HttpServletRequest
you have all the informations about the request, e.g.
the Cookies, the query-string, pathinfo, etc.

> Does this then return the file as a bytestream
> or something?

More or less. To enable the browser to interpret the byte-
data as image, you have to set the content-type header.

> Also, because this new servlet I will have made will
> only be reference with some servlet mapping in the web.xml file, will
> the still work in hosted mode?

No, you have to add a servlet-path-entry in your project's
gwt.xml-file.

> As for using the RPC servlet, I don't see how doGet solves my
> problem.  How is it fundamentally different form the doPost method
> used the the RPC?

It means, that you can also avoid creating a second servlet but
put in the doGet-method inside your RemoteServiceServlet. Because
a GET-request will lead to the execution of the doGet-method you
don't need to worry that you break something because all the
regular RPC-request are handled by the doPost-method.

But there is no reason, why you don't overwrite doPost as
well. You just have to call super.doPost(...) to let the
RemoteServiceServlet do its job. I use this for example for
file-uploading, i.e. I check if the request is a result of
a started file-upload and - if it's not - call super.doPost.

> And I what I need to know is even if i did use
> either of these methods, on a high level, how does the file get passed
> from the server to the client?

See above.

> I would feel comfortable diving right
> into either these without at least having a vague understanding of
> what was happening.

You can read about the servlet-API (that is used here) e.g.
at http://java.sun.com/products/servlet/2.2/javadoc/
for the low-level-information (aka Javadocs). There are
also tutorials out there, e.g.
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/


Regards, Lothar

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to