Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to transfer the csv file in the page?

 
Greenhorn
Posts: 14
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jsp code:
<script type="text/javascript">
     g2 = new Dygraph(
     document.getElementById("graphdiv2"),
     "file.csv", // path to CSV file
     {}          // options
    );
   </script>

file.csv is necessary to transfer to the page. It at me in a format MultipartFile.
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the tutorial and here's what it said about the CSV file:

the Dygraphs Tutorial wrote:In most applications, it makes more sense to include a CSV file instead. If the second parameter to the constructor doesn't contain a newline, it will be interpreted as the path to a CSV file. The Dygraph will perform an XMLHttpRequest to retrieve this file and display the data when it becomes available. Make sure your CSV file is readable and serving from a place that understands XMLHttpRequest's!



So that means your server has to send a CSV file when it gets a request for "file.csv". What you said about a MultipartFile (which I didn't really understand) seems to say you're thinking about a file upload. But that JavaScript code is not uploading a file. It's asking for a file which is already on the server. Maybe that file was uploaded earlier, but that is a separate issue.
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One:
Here, jsp file:

Two:
Framefork can accept the file as sequence of symbols. Though I am not sure. Example:
<script type="text/javascript">
 g = new Dygraph(

   // containing div
   document.getElementById("graphdiv"),

   // CSV or path to a CSV file.
   "Date,Temperature\n" +
   "2008-05-07,75\n" +
   "2008-05-08,70\n" +
   "2008-05-09,80\n"

 );
</script>
The file is saved in a heap. As @RequestParam(value="file") MultipartFile file.
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For experiment I tried:

METHOD in Controller:



JSP:



The browser to me was unpacked a hash an object code, in line:  <p>${filedata}</p>

[C@4167dbe5

How to print out all text and to throw in dygraph?:
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vadim titsi wrote:How to print out all text and to throw in dygraph?



A char array doesn't have a toString() method, so you get that output which looks like a hashcode. But I don't understand why you converted your String data in a char array in the first place. Just use the String as is.
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, use a String outputs data in the jsp.But it does not work in the designer:



I do not understand logic.
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vadim titsi wrote:I do not understand logic.



I don't understand the question. All you said is "does not work", which contains basically no information. What is the code supposed to do? What does it do instead? And more importantly, what is the code? Showing us some JSP code is pointless when your problem has something to do with the HTML that it generates. (At least I assume your problem is that... you didn't really say.) So if the problem is about the HTML, then show us the HTML.
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize.
Why I lay down ${filedata3} in a digraph (new Dygraph(....); ) and it does not work though logically has to. But when I lay down ${filedata3} in free space (<c:out value="${filedata3}" />)  of the html it works.

It has to be equivalent? If in ${filedata3} the same text is kept. ("Date,Temperature\n" +........)

 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To look at the HTML in your browser you can right-click the page and select an option something like "View Source". As I said before, showing us JSP is not very useful. Look at the HTML.
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!