Last time (hello world sample web app, June 01) I showed how to make a simple “hello world” same web app using Apache web server.
Today I’m going to talk about doing the same with Tomcat server with Eclipse plugin from LG. If you had a chance to look at document from LG developer lounge, http://developer.lgappstv.com, you probably have noticed that all document assume that you are using Eclipse plugin from LG with Tomcat. I know this is not the case with some of you, but I thought it’d be helpful to explain development environment that most document from LG developer lounge describes.
I’d appreciate if you add your comment on your favorite development environment when developing web apps.
=== Summary ===
Use Import from sample LG projects when creating your new project with Eclipse and Tomcat environment, and modify as you need. It just works! ^-^
=== Installation ===
Prerequisite: As I described in my previous blog (hello world sample web app, June 01), the followings should be installed already.
1) JDK for Java SE 6 from here
2) “Eclipse IDE for Java EE Developers” from from here
3) SDK for LG Smart TV from http://developer.lgappstv.com
4) Apache Tomcat from here
5) Eclipse plugin for LG Smart TV
=== Hello world web app with Tomcat ===
Details on how to develop web application described in lg web application development with lg smart tv sdk.pdf, which you can get from the LG developer lounge, Home->Document->Development Guidelines.
There are three ways to create LG project from Eclipse.
1) blank project
2) blank project, then import LG template
3) import from sample LG projects
I suggest 3) unless you feel very comfortable with Tomcat. 2) is okay but you need to add index.html to run it. I will cover 1) and 2) in my next blog.
Now I’m going to show you how to do “hello world” web app using 3).
A) First add a new LG project from the menu of Eclipse.
B) Select “Create Project From Sample Project” from Contents. Then I chose “PhotoApplicationReferenceCodeV1003” from the sample list.
C) From “Import Project” dialog, root directory and project should be selected already. Make sure and check “Enable Server Control Functionality” at the bottom. This would allow controlling Tomcat server from the project.
D) Now “New Server” dialog would popup to define a new server. All the selections were already made for me for Tomcat v7.0, so click “Next”.
E) All the projects are listed on the left side “Available”. Select “PhotoApplicationReferenceCodeV1003” from the left side and click “Add”.
F) The “PhotoApplicationReferenceCodeV1003” should show up on the right side as “Configured:”.
G) The new project should show up under Project Explorer on the left pane of Eclipse.
H) Now it’s time to run for a quick test. Go and click “LG Command –> Launch Emulator” menu.
I) Then select a project to run, “PhotoApplicationReferenceCodeV1003” in this case.
J) Emulator would start and a screen like below should show up. Note I started using SDK v2.1 as I posted before (SDK v2.1 released), so the screen shot below came from the VirtualBox-based emulator.
K) So far so good. This sample photo app runs fine, but it is “hello world” that I am trying to run. So let’s modify this sample project. The only thing you need to modify is “index.html” like below.
Index.html after changes
<!–DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>LG Browser Sample</title>
L) Then run it again by repeating steps H) and I) to see hello world. Here I’d like to show another way to run the web app within Eclipse. Right click “PhtoApplicationReferenceCodeV1003” project and select “Run As –> 1 Run on Server”.
M) Finally here is hello world within Eclipse.