How can I upload and download images with spark as our web layer?
I found this example but it heavily relies on Jetty being the container and does not work for Tomcat.
Would love to see a full example.
Why not just use a standard servlet with built in functionality?
Sample Spark Servlet Here
Sample Java Code Here
Related
Go easy please, I'm rather new to the whole web development thing and I'm a little perplexed.
I have the Spark framework installed from Maven, which has Jetty as its underlying web/application server, correct? Jetty is embedded in the Spark jar so I can't/shouldn't mess with it. Is that correct so far?
I read that Spark's embedded Jetty should support rendering of JSP files, however my browser is literally interpreting my JSP pages as text documents. How do I tell Spark/Jetty that it needs to interpret and serve these pages as opposed to just serving them as is?
I'm using Spark 2.5 and the velocity template engine.
Very minimal code so far. Rather than setting up a route to my JSP file I've just been typing the path into my browser while Jetty is running.
I've tested several different minimal JSP files this way.
I added a route in Spark to my JSP file and lo and behold, now it attempts to render the file! I suppose Spark has to handle the interpretation of the string passed to it and Jetty simply serves the content? Beats me! It works!
EDIT: Sorry to bring this back from the dead, but it doesn't have an answer yet and clarity was asked for so.... I added the route using the spark framework in my program, and used the render() function of spark to have Jetty render the JSP file. I had previously been entering the path of the JSP file as a static file, and so Jetty was not interpreting the contents of the file server side (as you would do with JSP) but instead trying to hand the file itself over to the client's browser. Rookie mistake!
I had developed a lucene search engine (with Lucene 5.2.1) and now I want to embed it into a very simple web application (it has demonstrative purpose, it will run in localhost).
This web application should let the user insert some keywords and navigate through search results (in other words it should let the user read the index that I had created, with appropriate html formatting). I had already made some simple html GUI with Bootstrap.
I'm very new to web applications, but I had been told that a good idea would be embedding Lucene in a TomCat server. I had visited this link, but it's quite old and not very detailed. I have tried to look for "lucene tomcat" but I get results about SolR or very specific posts.
Can anyone please suggest me a good resource or a general approach to my issue?
Many thanks
My solution:
I wrapped my search engine library into a JAR file.
I downloaded zipped version of TomCat 8 and installed it into my Eclipse environment as a new Runtime Enviroment.
I made a Dynamic Web Project in Eclipse (see this video lesson) using TomCat 8 server.
I put the JAR into my webapp (should be something like WebContent\WEB-INF\lib\searchEngine.jar)
I created a Servlet to handle user input.
I did the rest using very simple JSP pages, embedding Java code that uses my JAR (I know, that is not so good but it works!)
Cheers!
I'm searching for some good tutorials about implementations of uploading and downloading files (of different kind) in Java web services. I'd like to use latest Spring (core, context, web, webmvc), because I'm not into 'playing' with *.xml configuration files all the time ;). Unfortunately I managed to find only examples with writing own servlets. I’ve been told that easiest way for uploading is to use apache commons upload. Still I don't know an easy way for downloading.
I'd appreciate some example code or links to tutorials that would help. Thanks in advance :)
Let me google that for you "spring webservice upload file"
http://ltalbot.wordpress.com/2010/04/21/file-upload-using-rest-spring-mvc/
I would just like to ask if there is a way to upload files in GWT WITHOUT using the Google App Engine and Apache Commons archives? I've been searching for ways to upload files in GWT but all of the solutions I find all make use of these two. I would just like to know if there is a way, because our app won't work if we use GAE and Apache Commons... Thank you very much!
Yes, the simplest would be (assuming you are saving files to Blobstore):
On GWT side use FileUpload. Here is an example on how to use it.
On GAE side use BlobStore upload handler.
The other option would be to use gwt-upload with GAE upload handler.
GWT does not have such feature. You need to use some existing library or handle multipart form submits by yourself (FileUpload class). There is for example a gwtupload library which I have used and it worked pretty fine (but it is based on commons-upload AFAIR). There are other libs for sure.
http://code.google.com/p/gwtupload/
I want to upload multiple files using java: are there any articles on the subject?
Here's an excellent Java applet for uploading multiple files, including full source:
http://sourceforge.net/projects/jupload/
Your question is not clear. If you mean using Javascript then you can use libraries like extjs that provide control for multiple uploads
if you use java for web you can use jsp :
http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
Apache MINA has a ftp server written in Java - http://mina.apache.org/ftpserver/ - could easily be used with any ftp client to upload multiple files.