Vincent Oh

Ranch Hand
+ Follow
since Jan 02, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vincent Oh

I found the way already.
http://en.wikipedia.org/wiki/Comma-separated_values

and it uses \r instead of \n. and the sentence that requires to break need to be in quotations.

for eg.

"This is a\rbreak line"
will give
"This is a
break line"

11 years ago
Anyone has any idea to write a csv file with multiple lines in a cell? what is the special character needed to go to the next line? i tried /r and /n already, but it will go into a new row instead of next line in a cell.

thanks.
11 years ago
I have a table with checkboxes which indicate which files to download.
If it's a single tick, the file will be downloaded directly, if multiple ticks, it will be zipped and sent by the server.

Problem: How should I send user's choice (files which are ticked) to the servlet? I was thinking of concating the fileIDs into a String and sent it over via GET.

Is there a better way to do this?

Thanks.
11 years ago

Bear Bibeault wrote:No, you can just stream the data. Depending upon what the "file" is supposed to be -- apparently it's a big secret -- you need to set the response headers appropriately.



the file could be in any format like jpg, doc, csv, xls, etc etc. it's like an attachment function. how do you code the streaming from byte[] to the response? i always got problem with streams X_x
11 years ago
Convert it to something then i can return to the client side for download. Do i have to convert it to a File before writing it as a stream to the Response?
11 years ago
i'm using iBatis as my database connector. not sure if it can return a stream instead. any ideas?
11 years ago
GWT
My file is saved as a Blob object in mySQL database in the form of byte[]. How should i convert it in my servlet to send it back in the HttpServletResponse?

Thanks
11 years ago
hmm.. what if i need to do for a download upon clicking on a link?

i'm following this http://www.java-forums.org/blogs/servlet/668-how-write-servlet-sends-file-user-download.html

but how do i send the byte[] from the database to the HttpServletResponse in the servlet?
11 years ago
GWT
Hi, first of all, I'm not sure if i'm posting at the correct section since my problem cover across a few sections (I think).

Ok so here's the situation:

I have a saved record with a Blob field in the database saved in byte[] using iBatis.
So now I need to retrieve it through the servlet. And because I'm using SmartGWT, i will need to parse the record (in a JavaBean object) to a XML to be sent from the Server to the Client side.

Question:
How do I convert the byte[] into a proper data type so that I can parse it into a XML and send it over so I can display the picture on the client side?
If i decide to use a link which will allow user to click and download the image instead of displaying it directly, how do i do it?

Thanks and regards
Vincent
11 years ago
GWT
I need to limit the max depth a user can drag and drop a node.

For eg. Taking root level as level 1, i want to limit user to only drop till the 3rd level, in other words, only a tree of 3 levels is allowed.

I tried to change the node values onDropEvent, but it will create a duplicate with the changed valued and end up causing alot of errors due to duplicate keys.

Kindly advise, thanks!
11 years ago
GWT
Hi,

I need some help with TimeItem. Let's say that user input 01:00, how do I retrieve the values correctly?

If i do a getValueAsString(), it returns me "Thu Jan 01 1970 01:00:00 GMT+0800 (SGT)"
If i do a getValue(), it returns me "Thu Jan 01 00:30:00 SGT 1970"

Anyone know how to correctly get the 0100 out?

Thanks alot!

Edited:
I realised there's a getDisplayValue(). Hope it helps anyone who have trouble getting the value out.
11 years ago
GWT
It's ok, i got it using SortedMap map = new TreeMap;

Cheers.

12 years ago
Let's say i got a few double[2] : {a, b}

{3.0, 3.0}, {1.0, 1.0}, {2.0, 2.0}, {3.0, 2.0}

How do I sort them based on "a" so that I can retrieve the most frequent "a"?

I tried the following:



which prints



But how do i retrieve the value 3.0 which is "a"?

Thanks.
12 years ago
Hmm... I found some weird problem, see if any of you know what's wrong. I will just paste both codes here.

This is the code to test the servlet.


This is my servlet:



variable str prints the following:



After some testing, it seems that Class is not found at the server side for SimpleBean, which is indeed existing though. Any ideas anyone? The error logged from tomcat is as followed:

java.lang.ClassNotFoundException: SimpleBean
Continuing ...
java.lang.NoSuchMethodException: <unbound>=XMLDecoder.new();
Continuing ...
java.lang.IllegalStateException: The outer element does not return value
Continuing ...
12 years ago