views:

185

answers:

6

I posted this question: http://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help me out.

I read a few of the tutorials at sun. The basic syntax I understand. The thing I don't understand and really need to (because I think my company is going to tell me start working with this) is to learn how to work with java for the web. I am a php programmer and I did some asp.net c# a few months ago. I am really not understanding how to work with java on the web.

I installed netbeans. When I start a web project I also get asked what frameworks I want. I don't know any java frameworks (I do know about spring but never really worked with it). Is there no simple tutorial on how to do some java for the web??? I never had these much problems when I was first introduced to php :(

Someone help me out, or at least point me in a good direction.

+2  A: 

You may find this question helpful.

All you really need to know is HTML, Java, and JSPs.

Creating dynamic content is very easy using JSPs and Java. You also need a webserver like Tomcat or Glass Fish.

As far as the back end Java code goes, there is no difference between that and a desktop application. The only thing that you are changing is the user interface. One of the biggest challenges with switching to a web interface is the fact that it is stateless by design.

jjnguy
A: 

Are you familiar with MVC? There are multiple frameworks in Java that implement it. Struts is one of the more popular. It may help to start using Struts and work through a tutorial.

  • This tutorial is a good one that also will introduce you to spring.
  • This tutorial deals with struts in netbeans
There are some projects in java at my company that use Spring
AntonioCS
+1  A: 

The frameworks make web programming easier, they're not required. You can write web applications using plain old servlets and JSPs (with a web application container like Tomcat or JBoss) or even do all the HTTP I/O yourself (obviously that's pointless with Tomcat, etc, around).

A framework like Spring with Hibernate, etc, is similar to frameworks in PHP like CakePHP, they make development easier, they enforce sensible patterns (MVC) upon the programmer, the abstract code that is always going to be done the same way for this type of application. Yes, they limit your choices and abilities, and restrict the actions you can take, to varying degrees. Some are far more heavyweight than others. But there's a lot of choice in the Java world which is a strength, but you just have to spend time evaluating them, and picking one based upon your capabilities.

Take struts and tiles. You can simply use Struts as an MVC system and avoid all of the utility JSP tags it provides. It would take you a short time to rewrite the functionality you end up using yourself, but that's time you don't have, and then there's debugging, and specific domain knowledge and experience that you can't account for.

JeeBee
A: 

By technical side, you can start downloading Tomcat and code the exercises and documentation.

By "architectural" sie, you code in Java the business logic, that is all the components that take the parameter by communication client-server (request), manipulate this and use this for create the result.

this result is give to communication server-client (response) and it appear, with presentation layer (JSP, etc) in the web page.

The explication is very preciseless and not very "orthodoxe", I know. It's matter that you understand.

alepuzio
A: 

The programming model that is (in most cases) used when writing a Java web application is actually a subset of J2EE. Not a rocket science, but there's a need to know at least bits of it. Get yourself familiar with concept of J2EE Web Container, J2EE Web application, it's descriptor (web.xml), Servlets (which are, in fact the basic "building stones" of any J2EE webapp) and, of course, JSPs.

Sun has many nice tutorials on their's web pages. Googling any of the above terms with "site:sun.com" usually brings good results (e.g. this one about the concept of Servlets: http://java.sun.com/products/servlet/articles/tutorial/ ).

I'd also forget about web frameworks first, and start with the J2EE stuff, then MVC as a design pattern. After that, go into the web frameworks. Use of a framework is usually of a great help, but even when using one, you still need to know the basics.

david a.
A: 

Since you're using NetBeans, start with the tuturials they have on their site. http://www.netbeans.org/kb/docs/web/quickstart-webapps.html

Go through the simple tutorials on the site before you start going into the details on any frameworks.

Java webapps are pretty simple. You have your Java classes (.java) that handle your business logic and your .jsp files that handle the presentation. Try and keep them seperate. You also want to familiarize yourself with the JSTL tags and el (expression language) syntax