Meaningless Drivel is fun!
The moose likes Struts and the fly likes file uploading basing on a category Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "file uploading basing on a category" Watch "file uploading basing on a category" New topic

file uploading basing on a category

navi kumar
Ranch Hand

Joined: May 10, 2006
Posts: 47

cracking my head to solve this!!! help appreciated

I upload multiple files at a time.
this is the screen written in JSP. say it upload.jsp

File name 1 ___________ browse save
filename 2 ___________ browse save
file name 3 ___________ browse save

there are 6 categories of files in the database..for ex say marketing, distribution, sales, etc..

the add/edit screen lists all the 6 categories and provides a source to upload files.
the screen looks like this

marketing upload
sales upload
dist upload

when the user clicks on upload file corresponding to marketing the jsp window which i gave "upload.jsp" pops up and the user uploads the files and the files are saved in the database.

the corresponding table in d/b: "attachments" ( user_id, file_name, file_category, file_content BLOB, ......)
There is only one common table..we dont want to create a seperate table for each category (strictly)....

So, Along with the file(BLOB) the file_category should be uploaded to the database.

same is the process for all the categories.

the problem: I refered the same "upload.jsp" to all the categories and i am confused in writing the logic for categorizing the files uploaded.

The other problem is, I should list all the files in the specific category(say 'Marketing') when the user clicks the MARKETING tab...other category files should not be displayed. Also ..i should give the count of the files in a specfic category.

Any help is apprecaited.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You could just pass the category to the download JSP as a parameter:


The jsp could then preserve the value in a hidden field:

<html-el:hidden property="category" value="${param.category}" />

Then, when the form is submitted you can save it to the database along with the uploaded files.

Consultant, Sima Solutions
navi kumar
Ranch Hand

Joined: May 10, 2006
Posts: 47
Hi Merill,

The problem is not when i Upload, in the database table, i have a field holding file category.. so it would not be a problem for that.

But to display the files (BLOBS in the FILE-CONTENT field of the table) basing on the corresponding category.

for ex:

marketing xml.pdf
sales good.doc
marketing bad.xls

Now, i need to provide the user(MArketing) with a view containing files belonging to 'marketing' FILE-CATEGORY( xml.pdf, bad.xls)

I m not able to think a sol'n for this!!

Help me out.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Maybe I'm not understanding the problem here, but this seems fairly simple to me. Just write a query .. select * from uploadedFiles where category = 'Marketing'. Is there a reason a simple query like this won't work?
I agree. Here's the link:
subject: file uploading basing on a category
It's not a secret anymore!