0

Hi I had today my first interview for a position of android developer.In my portfolio I had a php e-commerce application that has a catalog , ajax powered shopping cart , and administrator functionality.

Because my Android knowledge is prety limited , I only started learning about 3 weeks ago , I was asked to migrate my current PHP web appplication to Java Web until April 19th when the second stage of the interview will take place , so they can asses how fast I can learn a new technology.

I have no experience with Java working on the web so I do no know where to start.

After a bit of research I found that for developing website with Java usually you use JSP, Spring or Struts.

I would like a recommendation on witch one should I learn to quickly get started on migrating the web application to Java and some resources that do not get into to mutch details just enought to get started.

9
  • 1
    Spring is the more widely used framework for new development today.
    – user40980
    Mar 25, 2013 at 18:25
  • But what about JSP fro what I read on other pages a beginner should start with that.Is it not necesary to learn JSP first?
    – aleczandru
    Mar 25, 2013 at 18:27
  • JSP itself is very php like. You write html and either specialized tags or raw java (scriptlets - though they've fallen out of favor over the years). This likely won't be where the learning curve will hit you hard.
    – user40980
    Mar 25, 2013 at 18:30
  • 13
    Seems Like a lot of work for an interview...
    – Morons
    Mar 25, 2013 at 18:37
  • It's my first job so I need the experience
    – aleczandru
    Mar 25, 2013 at 18:40

2 Answers 2

2

I had to migrate a large PHP application to Java a few years ago. I chose to migrate to plain Java + JSP rather than using a framework, and it worked out quite well for me; I find that serlvets + JSP + JSTL is extremely powerful and flexible, and doesn't bog you down too much.

I would highly recommend plain Servlets+JSP for your case if for no other reason than it will show you the core foundation of Java web development, without spending too much time learning a framework that you don't know they're actually using. If you know they're using Spring or Struts or anything else, by all means, learn that specifically; otherwise, learn the foundation and work your way outward from there.

1

I don't think Java web development will have any direct bearing on Android development apart from serving as a generic gauge of your ability to acquire new topics on your own. There may be some logic to this though as getting your first "Hello world" style Android program up and running involves a substantial amount of setup work. In the case of web development, there's much less setup (but still a small amount, more on this below)

As a PHP developer, plain old servlets + JSP will likely be closest to your mental model (as Adrian pointed out). One of the big differences is that you will have access to the application context where you can store global objects and the session context where you can store user/session specific objects. This gives you the ability to have state in your web application without constantly hitting a database or rolling it manually with memcached or similar. Another difference is that Java has the concept of a web application. A web application is a single file with a .war extension. if you're curious, you can unzip the .war file and you'll see inside a tree with various files and folders, including your JSPs as well as various config files, compiled classes, other jar files etc.

Application Structure

Using plain old servlets and JSP, you can implement the concept of MVC by structuring your code as follows:

  1. Create a servlet called controller. The job of controller will be to carry out any actions required. Controller won't have any presentation logic in it. In a hypothetical shopping cart application, controller would know how to update the cart, submit the order, log the user in etc.

  2. Create various JSPs for each view. For example, you might have a cart.jsp for displaying the shopping cart.

Your JSPs should only be used for presentation only, not logic (that belongs in the controller)

This should be enough to get the basic idea. FYI, the JSF framework takes the above idea and formalises it. That is, you create a file which declares all of the actions that can be taken and which view should be shown following the action. The controller is implicitly created. I would recommend staying away from JSF unless you are familiar with JSP/Servlets.

There are other frameworks such as Struts and Shale that play a similar role and I would likewise consider them to be best approached only when you know JSP/Servlets. There are plenty of analogies to this in the PHP world such as CodeIgnitor, Yii etc. etc.

Spring is substantially bigger than JSF/Struts etc. It may be worth learning in the long run but becoming productive in Spring would likely be a substantial undertaking for most experienced Java developers.

Getting set up for web development

My own personal view is that it's hard to beat Netbeans for ease of use when getting started. Netbeans comes in different bundles; if you download the JavaEE bundle then it will come with Glassfish and Tomcat bundled. Glassfish provides a superset of the functionality provided by Tomcat but for plain old servlet/JSP applications, you can use either.

I recommend glassfish which is slightly better integrated with Netbeans. In this case, integrated means that you can click the "Run" icon in Netbeans and it will result in Netbeans doing the following:

  1. Start your server if it's not running
  2. Build and deploy your web application
  3. Launch a browser pointing at the appropriate URL

Tomcat will work equally well but I think support for debugging from Netbeans is better in Glassfish.

Not the answer you're looking for? Browse other questions tagged or ask your own question.