JSP Performance Question

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

JSP Performance Question

Postby sbutler » Mon Jan 22, 2007 11:52 pm

I have a JSP page that takes in fileName and filePath parameters, and downloads the file to the user. The code executes fine, but the server's CPU is maxed out during the time the file is downloading. When copying a 5 MB file at about 300KB/sec, it takes around 15 seconds, and I really don't like having the server maxed for that long....and that is just 1 user. It just seems as if streaming a file really shouldn't take that much CPU. Also, the machine is only a 1.25 Ghz G4 Mac Mini (for now).
I have copied the code below.

Code: Select all
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
   ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
   if (servoy_hc == null)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"jsp_docmgt");
      session.setAttribute("servoy",servoy_hc);
   }
   boolean ok = servoy_hc.setMainForm("jsp_docmgt_main");
   if (!ok)
   {
      out.print("error cannot work on required form");
      return;
   }
   
    String filename = request.getParameter("fileName");
   String filepath = request.getParameter("filePath");

   response.setContentType("application/octet-stream"); 
   response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");

   java.io.FileInputStream fileInputStream = new java.io.FileInputStream(filepath + filename);
 
   int i;
   while ((i=fileInputStream.read()) != -1) {
      out.write(i);
   }
   fileInputStream.close();
   out.close();
%>
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 5 guests

cron