• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to make locate file on server through attachment icon

 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my project i am saving messages in one table and file path in another table.
in this users can save messages along with the file attachment but file attachments are not compulsory. messages can be save individually.
so i want to show attachment as icon along with the messages in table through which the user can locate the file on server and can download on its computer, like we used to do emails.

please suggest me some example how can i do this using jsp.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How far have you proceeded so far, and what exact problem are you facing?
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:How far have you proceeded so far, and what exact problem are you facing?



i am able to extract messages from database in the table but now i want show attachment icon along with the message if the user has attached any file.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must be having a mapping between these two tables right? Probably a one to one relation using some key.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:You must be having a mapping between these two tables right? Probably a one to one relation using some key.



yes as i mentioned above i am using two tables one for saving messages and other for file handling.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, what is the exact problem? Retrieving the file path from other table, or displaying the icon in the UI table?
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:So, what is the exact problem? Retrieving the file path from other table, or displaying the icon in the UI table?


actually problem is both but main problem how to display icon as attachment will not be along with all the messages, so for some messages only icon has to display. for this problem i am not able understand what approach i should take.

 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not too sure what query you have to retrieve the message and the file path from the underlying tables. However assuming that you are retrieving the message and it's corresponding file path. Once this is retrieved you can check what file path contains. If it is not empty display the icon or else leave that cell blank , and you can have a utility method like this to check whether it is empty or not.

 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for retrieving data from the text area and inserting into table i am using following code


for file uploading i am using following code


These are the applications which i have made separately now i want to combine these two applications so now please tell me where i have to use your code.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:


The String class has a built in isEmpty method which does exactly the same :). So calling data.trim().isEmpty() should suffice.

@Megha
In pseudo code.
Create a custom object to hold the message and fileName/filePath/fileId/whatever (among other things)
Populate this object and send to client
On the client check if the file related information exists. If no information is available do not show the icon
Create a servlet. This will accept the fileName/filePath/fileId/whatever and serve the file back to the client.
Invoke this servlet when the user clicks on the icon.

You can search the forums for servlets which can help the client download a file. In case you run into any problem, show us your code, tell us where you are stuck, and we will help point you in the right direction
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess none of the above codes deal with displaying the table to the use that you talked about (message and the icon). It would be good if you clarify few things.

1. I can't see any relation between these two tables, so how do you identify which message is for which file path?
2. Why are you using two different tables, any issues if you use a single table with two columns to store the message and file path?
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:I guess none of the above codes deal with displaying the table to the use that you talked about (message and the icon). It would be good if you clarify few things.

1. I can't see any relation between these two tables, so how do you identify which message is for which file path?
2. Why are you using two different tables, any issues if you use a single table with two columns to store the message and file path?



actually above are example codes which i am using for testing purpose. i have separately prepare the main table but i can apply those table only when i understand what query i have to run to link these tables and hyperlink the attachment icon so i can display along with the message.

i know the design of tables but i can use them only when i know what approach i should follow.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the approach is clear to you now.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:I guess the approach is clear to you now.



not sure whether i could make it but no other option i have to try.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic