Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Loading diff. images in a webpage using servlet

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how diff. images are loaded using threads to a web page using servlet.

I want to make the loading process fast by using multiple threads. Is it using file io?

Can anyone please give me some idea on this?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the question is not very clear.
 
Srikanth Penta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not saying clearly,

I want to display 20 images in single page. Its taking more time. So I want to make that process fast by using threads. i.e want to reduce the loading time of the page.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on the actual problem, it isn't really a Servlet or Java question.

Firstly, most resources in a page tend to be loaded from the client using a single 'keep alive' connection since this is faster and more efficient than trying to negotiate a new connection for each resource. There are some exceptions to this since some resources need to be completely loaded (eg javascript files) before related files can be determined.

Secondly, clients and servers tend to limit the connections allowed to prevent one page or client hogging the system. Hence even if you managed to force many connections to be created from the client, the third onwards may be blocked until the first ones finish.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the client in your case is browser then you cannot do anything , you cannot enforce and restriction from the server side.

As establishing TCP/IP connection is a costly affair , so it keep the connection open and uses the same for getting other resources for constructing the page.Now sure whether browsers use multthreading for requesting multiple resources at a time.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you certain that the problem is not one of limited bandwidth - how big are the images, and what kind of connection is used?

Also, I don't think a browser would use N download threads to download N images. For a given web page, I think no more than about 4 threads are used by default. Some browsers have a setting for this.

As to addressing the problem on the server, typical web containers like Tomcat already use a pool of threads to handle requests. So if 20 requests come in (unlikely, see above) the server might well be using 20 threads to serve them. The same is true if the images aren't static, but are generated dynamically by a servlet (which is multi-threaded by nature, unless SingleThreadModel or synchronization is used).
[ May 04, 2007: Message edited by: Ulf Dittmer ]
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic