views:

130

answers:

7

Everything I download seems hellbent on using all of Java EE. I need to build a single page to handle requests to it and do a tiny bit of processing based on parameters. This is to hook into another framework that will routinely call this URL.

I want a quick and easy way to create a page with some processing. Is there an easy way to do this using Java? I am using Java because I am comfortable with Java. I used SE for years and did some work in EE but I don't want all the stuff that comes with EE.

Should I maybe just avoid Java altogether and use something else. This needs to be deployed in a linux environment.

+1  A: 

It sounds like you could use PHP to do your processing. Call the page and POST the parameters to it, compute, and return the result.

ryangavin
Recommending PHP in a Java question is like throwing Natrium (*aka Sodium*) to water.
Esko
@Esko: The OP *did* say he was open to using something other than Java if it would be even easier. In fact, if the OP is a strictly Java-only guy, this might be a good chance to dabble in some other technology, though it will take longer to get up and running, with learning curves of new tech and such...
FrustratedWithFormsDesigner
Definitely open to anything at this point. I was considering dabbling in Ruby On Rails. Only reason I am opting for Java at this point is because I have the most experience with it.
uriDium
@uriDium: Though if you have spare time after the Java implementation, try porting to PHP, just to see what it's like. You'll learn something new. :)
FrustratedWithFormsDesigner
@Frustrated: I'm not saying it isn't a good recommendation, just that based on my experience PHP is seen as the antichrist of scripting languages among Java devs which may cause heated verbal battles very easily. Thankfully that didn't happen here, I was worried this would end up like 99% of PHP discussions I've had lately.
Esko
I dev with both Java and PHP depending on the project. Each has its uses, pros, and cons.
ryangavin
+4  A: 
  1. You need Tomcat (or jetty, or any servlet container - jetty has an embeddable version btw)
  2. You need a .jsp file and optionally an HttpServlet

Generally, it's not a good practice to put any processing code in a JSP, but if it is really simple and won't be extended, simply put the logic there - it is translated to a Servlet anyway.

Bozho
The OP doesn't **need** Tomcat or whatever, he **could** use Tomcat or Jetty or JBoss or GlassFish or WebLogic, etc. The runtime environment doesn't really matter, the point is that the OP can use a small part of something big.
Pascal Thivent
@ Pascal. But I don't want to download Java EE if I can avoid it. And I especially would prefer to avoid the pain of JBoss if or some other application server if I can avoid it.
uriDium
@uriDium: That's not my point. My point is that even if your company is running all its project on a corporate full Java EE server, you can use a tiny part of Java EE. Now, if you have the choice, Tomcat or Jetty will be fine for a single Servlet application.
Pascal Thivent
A: 

I would reccomend Sinatra it is a very light-weight ruby web framework.

Maz
+4  A: 

I used SE for years and did some work in EE but I don't want all the stuff that comes with EE.

Then just use a Servlet and that's all. Nothing, I repeat NOTHING, forces you to use "all that stuff" and your question is either a free rant or shows some deep misunderstanding.

Pascal Thivent
+1, agree. The problem I find is most tutorials assume you WANT to use everything and the kitchen sink, so they write contrived and overcomplicated examples of simple things using very heavy EE stuff. I'd like to see a tutorial that covers a web page in Java with the absolute *minimum* of fuss and bother, but they're hard to find.
FrustratedWithFormsDesigner
Probably deep misunderstanding to be honest. I never really got the EE architecture that well. I did just a bit. For the most part I did SE stuff in a server environment.
uriDium
@uriDium: No problem. What I don't get is that part that makes you think you can't do "simple things" with Java EE. As I wrote, just write a `Servlet`, that's all you need.
Pascal Thivent
@ Pascal, my ignorance once again. But as far as I knew I had to have an application server when I started using Java EE. I thought Java EE had all the message queuing and inter-process communication. So I thought it would be better to just avoid the whole thing. If you have used ASP.Net I am almost looking for a simple webpage with a code-behind. I have even considered using mono and doing just that. Thanks for your feedback.
uriDium
@uriDium: You seem to be using *Java EE* to refer to the *runtime environment* (a Java EE app server) while I consider *Java EE* to be the *API*, hence the confusion. So, as I wrote in another comment, a servlet container (i.e. not a full Java EE server) will be fine if you only need the Servlet API.
Pascal Thivent
A: 

If you are not very particular about using java and are willing to experiment, you should look at nodejs. It runs on V8 javascript engine and runs on linux. There are a couple of fraemworks for nodejs for web apps:

Expressjs and spludo

naikus
A: 

as mentioned, you can do this very simply with jetty and a servlet, you don't even need a JSP if you just need a URL that does some processing based on request parameters and returns a response.

For development, it's really easy to create a dynamic web project in eclipse, just follow the steps in this article.

That said, I don't think java is a great choice for really lightweight stuff. PHP is probably the easiest thing to use if you just want to get it working yesterday.

Paul Sanwald
+1  A: 

yes, all the servlet based solutions are quite chubby.

jetty is all right, but the download is 20MB. that is ridiculous.

currently, the best choice is probably com.sun.net.httpserver which is bundled in JDK 6. you can easily implement your service.

irreputable