How to start with java on the web

I am totaly new to java. My first web language is PHP and I think, that I am good at it

But ... now that I have finished some PHP projects I am getting sick of it.

It was fun on the start, but when my web's grow, then it isn't fun anymore. I have to write some things over and over again. It is very hard to find errors in such php webs ... If you look at .php files with all those echoes and stuff, you cant figure anything out. PHP is good for small pages (OK, you can also write big ones, but you risk a headache).

So what I am looking for is a language that is capable of separating code from design, possibly object oriented and open source.

I think that java fits here. Where should I start ?

If I got it correctly then JSP-s are almost the same as PHP ...

What should I use then ? I hear a lot about EJB an servlets. Do they give me what I want ? Do I need JBOSS ?

EJBs would probably do what you're looking for. It sounds to me like what you're needing is more of a JavaBean or taglib.

JavaBeans usually contain business logic. You can use tags to get and set properties, or use code to call methods directly. The can be scoped to the page, the request, the session, or the application.

Taglibs are (basically) a way to encapsulate the passing of parameters to an include. Kind of like function calls that don't return values.

You could also just use plain old java objects. The disadvantages of these over javabeans is that you can't get and set properties through tags, and if you want to scope them to the session or application you have to do it explicity.

You can duplicate the last option in php, though. Put your class definition in a seperate file, say "UserClass.php", the in your page you just include( "UserClass.php" );, the instantiate an object: user = new User();