Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 16th, 2003, 08:09 AM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With servlet getContentLength()

Hi,
I am using sun one application server 7.0 i am writing an application for uploading files. I want to restrict the uploading size. I am testing this with request.getContentLength() method. Which is working on Tomcat but failing on sun one when file upload size is more than 1MB.
My code fragment is like this:


if(request.getContentLength() > fileLimit){
log.warn(" Upload size is more than file Limit");//Line 1
request.getReguestDispatcher("/upload.jsp").forward(req,res); //Line 2
}

I am getting page not found in the browser.
i replaced line2 with getServletContext().getReqDisp().forward() method and also with out.println(), same result.
is there any workaround for this??

Any suggestion!? Thanks in advance!!
 
Old February 23rd, 2004, 11:22 AM
Registered User
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to IgorT
Default

You can't acquire content length from request if it hasn't been set by client(in HTTP header). You can read the stream up to 1Mg and then cancel it.
 
Old May 21st, 2004, 11:55 PM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if so, it should fail on all webservers but my observation was its failed only on S1AS 7.0.
Ok anyway thanks for your comments.
 
Old May 28th, 2004, 04:18 AM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to uskiranj
Default

hi reddy
try the following
request.getReguestDispatcher("full jsp file path").forward(req,res);
regards
kiran kumar j






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with servlet developer.ibm Servlets 1 September 12th, 2007 11:22 PM
My servlet problem saeed Servlets 1 April 10th, 2007 07:12 AM
servlet Problem discuss Servlets 3 February 6th, 2007 02:06 PM
servlet problem discuss Servlets 1 August 29th, 2006 10:03 AM
Servlet problem Ravi Kumar Servlets 1 June 20th, 2005 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.