IntelliJ open source
[Logo] JavaRanch » Big Moose Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
Author

How to check the file size?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

Dear All,

I my application I'm checking the size of file in server side(servlet) So when i upload file (above 20mb) Its Taking too time to parse the request in server side.As i'm using appache API to parse the request ,and i also tried in browser side using java scripts but it's not compatible with Mozilla and other browsers please can any body tell me the solution to over come .so that when i upload more than the limit it should alert me

This message was edited 2 times. Last update was at by Bear Bibeault


Creativity is nothing but Breaking Rules
Bear Bibeault
Author and opinionated walrus
Sheriff

Joined: Jan 10, 2002
Messages: 36608

If you are asking how to check the file size on the client, that's not going to happen. Security concerns prevent client code from knowing anything about the file system.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

So can i use ajax or Applet to check the file size..?

Creativity is nothing but Breaking Rules
Bear Bibeault
Author and opinionated walrus
Sheriff

Joined: Jan 10, 2002
Messages: 36608

How on Earth would Ajax help?

You might be able to use an Applet -- but the user will have to accept letting the applet check the file system. There's no guarantee that they'll say yes.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

Is it possible improve the parsing request performance in server side

Creativity is nothing but Breaking Rules
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Messages: 519

On the server side, can't you just check the content-length header and refuse the connection if the size is too large?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Messages: 7199

Mark E Hansen wrote:On the server side, can't you just check the content-length header and refuse the connection if the size is too large?

I believe the Apache file upload product provides something which allows you to do that. I don't have the documentation handy but it shouldn't be too hard to look it up for somebody who does have the documentation.
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

I believe the Apache file upload product provides something which allows you to do that.

Please can any body give me the documentation or some hint regarding this

Creativity is nothing but Breaking Rules
Bear Bibeault
Author and opinionated walrus
Sheriff

Joined: Jan 10, 2002
Messages: 36608

Please ShowSomeEffort.

This took me about 30 seconds to find on Google.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

On the server side, can't you just check the content-length header and refuse the connection if the size is too large


I had used the request.getContentType() in my condition to check the file size it will take < 1 sec now to give me the content length but when i redirecting it it ll take 5 min to redirect



Creativity is nothing but Breaking Rules
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Messages: 519

Can you please check the API and see what request.getContentType() returns?

Is it giving you what you expect?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

Sorry for the previous code


Creativity is nothing but Breaking Rules
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Messages: 265

Please can any body tell me why redirecting taking too much of time to redirect

Creativity is nothing but Breaking Rules
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
IntelliJ open source