gnieh / tiscaf

lightweight HTTP server for Scala
GNU Lesser General Public License v3.0
23 stars 7 forks source link

some tutorials for beginners? #1

Closed xuchen closed 11 years ago

xuchen commented 11 years ago

(Sorry to mark this as an "issue" as I didn't find another way to communicate)

I like the minimalism setup of tiscaf. As an absolute newbie the "Getting Started" wiki and HomeServer example are still a bit too hard to me. Is it possible to provide some more tutorials on how to use it? I think a re-implementation of the following example with tiscaf would be excellent:

http://veerasundar.com/blog/2008/12/implementing-ajax-in-java-web-application-using-jquery/

Thanks!

satabin commented 11 years ago

Hi xuchen,

I will have a look at this example and see how I can adapt it to tiscaf. Thanks for the suggestion

xuchen commented 11 years ago

Nice! Thank you!

satabin commented 11 years ago

So I made a first tutorial that you can find here: https://github.com/gnieh/tiscaf/wiki/Simple-Time-Server The code is also available in the repository. I hope this helps!

xuchen commented 11 years ago

Excellent! Thank you so much! I'll try it out.

xuchen commented 11 years ago

I got a simple question on the classpath of TimeServer: it runs fine from sbt, but when I tried to run it through eclipse, I always got a "404 Not Found" error, indicating the static page can't be found. I tried to set the classpath to the folder containing "index.html", or rewrite the dirRoot field in ResouceLet, none worked. What did I do wrong here?

satabin commented 11 years ago

For this test to work in eclipse, you can probably use sbteclipse to generate the eclipse .project and .classpath files

But actually if you have examples/time/src/main/resources in your build path it should work....

xuchen commented 11 years ago

Yeah you are right. I originally set the classpath through the "VM arguments" box in the Run Configuration (just like how I specified other options such as -mx). But it looks like Eclipse intentionally strips classpath from this box: https://bugs.eclipse.org/bugs/show_bug.cgi?id=126499

Then I set the classpath with the Build Path. Now it works. I also managed to adapt the TimeServer with sending/receiving JSON objects. It's working great! Thanks again!

xuchen commented 11 years ago

(hopefully the final question) how to deploy the server?

I have a homepage on school's server, with an address like http://myschool.edu/~xuchen

How do I deploy it so users can access it via something like:

http://myschool.edu/~xuchen/timeServer:8080

Currently I can access it perfectly from localhost:8080 Thanks!

satabin commented 11 years ago

This problem is not that easy to solve. Your school probably blocks the port 8080 or at least does not redirect it... Your homepage is served by the http server from your school that looks into your home directory for files. But it probably does not allow you to have your own server running and accessible from the web. You should ask to your system administrator if this is allowed (but I doubt it is)

xuchen commented 11 years ago

The IT support said the 80/443 ports are open. However, they only allow CGI scripts on their web servers. Any idea on letting CGI talk to the scala server?

satabin commented 11 years ago

This is probably not the best place where to ask (ticket should be tiscaf related, try to ask google instead about scala + cgi), and I can't discourage you enough to try running scala code in a cgi script as this would start a new JVM for each request. Moreover, tiscaf is a standalone web server, not something that is meant to run in another web server. What you would need here is to have the web server of your school redirect requests on port 8080 to the computer running your tiscaf, acting as a proxy. But once again I really do doubt that your school will allow that

xuchen commented 11 years ago

Yeah, a new JVM per each request, that's also what I learned from Googling. Thanks a lot! I'll talk to our IT support then, or set up a serve elsewhere.