(keitai-l) Re: "i-appli taking long time connecting to servlet"

From: Kapil Sharma <kapes.endless_at_gmail.com>
Date: 06/08/05
Message-ID: <e4569d7f050608003146ef9d3b@mail.gmail.com>
"It is taking so much time ".

Is it like that my i-appli get the connection ok response only when
servlet stops it's entire execution (my servlet is sending  30 images
to my i-appli inputstream(in repeated manner) ) as i given the
following code in my previous mail.

Thanks 

Kapil Sharma

On 6/8/05, Kapil Sharma <kapes.endless@gmail.com> wrote:
> My i-appli code is the same as you have written here.Also i am
> connecting to my servlet through this connection and then my servlet
> send images as chunk in the inputstream of i-appli.
> 
> As stated My i-appli program doesn't take much time connecting to
> servlet and getting simple string data from it (through printwriter
> servlet API).
> 
> Is that means my servlet is taking so much time connecting to i-appli
> and then sending images from it's local foder . Can i optimize code on
> servlet side.
> 
> My servlet code looks like
> 
> // sending 5 image files to outputstream
> public void doPost(HttpServletRequest req, HttpServletResponse resp)
> throws IOException {
> 	
> 	int i;
> 	String filename=null;
> 	FileInputStream in=null;
> 	String mimeType=null;	
> 	File file=null;
> 	int count = 0;    	
> 	int c_length=0;
> 	String type = null;
> 	String f_length=null;
> 	ServletContext sc = getServletContext();
> 	byte[] buf = new byte[3000];   
> 	resp.setContentLength(15000);        
> 
> OutputStream out = resp.getOutputStream();            
> for(i=1;i<=10;i++)
> {
> 	filename = sc.getRealPath("image"+i+".jpeg");//get path of image locally
> 	file = new File(filename);
> 	mimeType = sc.getMimeType(filename);
> 	resp.setContentType(mimeType);
> 	in = new FileInputStream(file);     
> 	count = in.read(buf);
> 	out.write(buf,0,count);   
> }
> 	in.close();        
> 	out.close();   
> 	
> 
> 
> On 6/7/05, Peter Van der Weeen <pvanderweeen@cerego.co.jp> wrote:
> > >Also at server side do we need to do some kind of caching
> > >Could anyone tell me why this is taking so much time and also what
> > >optimized code to write on server side
> > It depends on what you're trying to do here, but caching is normally not
> > required.
> > 
> > How long does it take to download a small graphic or static text/html
> > file to your appli?
> > If that's fast then you have indeed a problem on the server side. If
> > that also takes 20 secs, then I'd spend some time looking at the appli
> > source instead.
> > 
> > 
> > If you're using DoJa then I guess your code looks similar to the source
> > below, is that correct?
> > static byte[] immediateGet(String p_location) throws Exception {
> > byte[] x_data = null;
> > InputStream i = null;
> > HttpConnection c = null;
> > 
> > try {
> > 	c = (HttpConnection) Connector.open(m_url + p_location,
> > Connector.READ, true);
> > 	c.setRequestMethod(HttpConnection.GET);
> > 	c.connect();
> > 	i = c.openInputStream();
> > 	x_data = handleResponse(c, i);
> > }
> > catch (Exception e) {
> > 	throw new Exception("Exception occurred");
> > }
> > finally {
> > 	if (i != null) {
> > 		try {
> > 			i.close();
> > 		}
> > 		catch (Exception e) {
> > 		}
> > 	}
> > 	if (c != null) {
> > 		try {
> > 			c.close();
> > 		}
> > 		catch (Exception e) {
> > 		}
> > 	}
> > }
> > return x_data;
> > }
> > 
> > With the above routine, it takes typically 3-6 seconds to set up an
> > connection from your phone. From the emulator it's almost instant so we
> > concluded that this delay is caused by going through Docomo's systems
> > rather than the webserver. you're talking to. After the initial
> > connection has been established, uploads and downloads are pretty fast.
> > 
> > Anyway, you should be able to find more information on this on the web
> > and in (Japanese) DoJa programming book.
> > 
> > 
> > Peter 
> > 
> > 
> > This mail was sent to address kapes.endless@gmail.com
> > Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/ 
> > 
> >
>
Received on Wed Jun 8 10:31:20 2005