Place GWT application on Jetty - gwt

Can someone help me to place my GWT application on Jetty. I am not using maven. I have libraries in my build path.
First I am taking the war folder already exploded and copy it in jetty/webapps, then in folder context.
I have placed a folde named BiddingSystem in folder web apps, it is an already exploded folder and not a .war file
In folder jetty/context, there is a file test.xml
I am renaming the file to BiddingSystem.xml
and also editing content of BiddingSystem.xml, finally the content of BiddingSystem.xml is
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<configure class="org.mortbay.jetty.webapp.WebAppContext">
<set name="contextPath">/BiddingSystem</set>
<set name="war"><systemproperty name="jetty.home" default="."/>/webapps/BiddingSystem</set>
</configure>
I am getting this error:

to deploy GWT app on Jetty, you often do not need to configure anything.
Copy your 'war' folder (which is created in your eclipse project by GWT) to JETTY_HOME\webapps
change the name 'war' to anything you like for examples "StockWatcher" so you will have JETTY_HOME\webapps\StockWatcher. Now start jetty server and try http://localhost:8080/StockWatcher on your Chrome :)

When GWT is compiled it creates just javascript and html (plus resources like css/jpg/etc..). GWT jars and your Java classes are only used during build process and NOT needed during deployment.
So, you just need to copy contents of you /war directory to your Jetty deployment directory.
There is a .html file which is called host page. It links to all other javascript and css pages needed. This is the entry point to your app. Just open this page in your browser.
It seems that you are new to GWT so there are a few basic things you need to know:
GWT is a client-side technology. You write Java code which is compiled to javascript that then runs inside browser. In this sense GWT is more related to javascript libraries (jQuery,..) than classic page-by-page web frameworks (jsf, Ror, php).
GWT app runs inside a single HTML page (called a host page). This page ever reloads. Look at Gmail to see how this works (though Gmail itself is not written in GWT) .
GWT is NOT a server side technology. You can use any technology on the server side (php, RoR, anything) that supports REST.
GWT can talk to server via AJAX. The data exchange format can be JSON or XML. Backend can be any technology that can produce REST-style JSON or XML content. If you have Java backend you can use GWT-RPC which adds some more capabilities over AJAX/JSON.

Related

gwt beginner- getting error when I make an RPC call on server- same code works in gwt dev mode

I have created a simple gwt application (with gwt 2.4) that makes a single RPC call.
When I run this in GWT Dev mode, it runs fine, however when I try to run this on a server-
this is the message that I get --
POST http://app.sparkcrawler.com/com.arvindikchari.auth.App/AuthenticationService 404 (Not Found)
I have copied all files from the WAR folder in my Eclipse GWT project, to the web server's folder. The web server uses Tomcat 5.5(with Cpanel control panel). I copied these files, after successfully compiling the files ("GWT Compile Project")...
What have i done wrong here? Have i missed some files? I have copied everything from war folder, including "WEB-INF" folder and its contents, to the web server.
I think, copying the Eclipse project's WAR folder is not the appropriate way to deploy a GWT application to a server.
You first have to compile for production mode (see Understanding the GWT compiler), then with the resulting JavaScript files, create a WAR including server side classes which you can deploy to a Tomcat server. (See Deploy a GWT Application)
You can use Ant or Maven to automate this process.

URL mapping of servlets and JSP files with Tomcat and Eclipse

I have a web application project in Eclipse that is configured to deploy to a local Tomcat server. Let's call the web application Blah. Here are two questions -- I must be missing something very simple, but I can't find an easy way to change these settings within Eclipse without fiddling with the Tomcat configuration files.
1.
When the application is deployed, the URL I can use to browse to some servlet/JSP is localhost:port/Blah/servlet. I would like to get rid of the Blah prefix.
2.
I would like to set up redirects for some JSP files to "hide" the .jsp extension. For example, I'd like localhost:port/login to be served by localhost:port/login.jsp, preferably without the browser seeing a 30x redirect status code.
3.
I would like to set the default URL, i.e. localhost:port/, to redirect to a particular JSP or servlet (again, preferably without issuing a redirect status code).
Any help, including links to relevant resources, would be greatly appreciated. Please note that I am looking for a way to configure these things from within Eclipse, if possible. (If not possible, I would like to do the minimal amount of changes to the scary Tomcat XML files.)
This means that you need to deploy your application as the root application. It's easily done by naming your war file ROOT.WAR (or your exploded war directory ROOT), or by defining a context for your web app with an empty string as the path attribute.
Then you don't want a redirect, but a forward. Or you simply want to map the JSP (which IS a servlet) to a given path. Define a servlet and a servlet mapping in the web.xml file, as you would for a servlet class, but use <jsp-file> instead of <servlet-class>.
This is done using the <welcome-file-list> element in the web.xml.

Editing a .jsp file from an App Engine project in Eclipse

I am currently creating my first project using Google App Engine in Eclipse. For my main page it seems I can create either:
a servlet (class that extends HttpServlet)
or I can create a jsp file.
Is there a way in Eclipse to make it aware of the java code in a jsp file and to use all the IDE goodies such as colored text, inline documentation, auto-complete? And is there a way to auto build and validate the code in a jsp or it can only show the errors on the first load of the web app?
It seems to be a lot easier to develop in a servlet class than in a jsp file. Or did I miss something?
Eclipse tries to validate the markup and autocomplete it in the JSP files if you have the WTP (Web Tools Platform) installed. But even that sometimes doesn't work well because it's difficult to parse HTML containing JSP tags, Javascript, etc.
Regarding the Java code : it's bad practice to have Java code in scriptlets in JSPs. You should only use JSPs for pure presentation logic, and use JSTL and custom tags for that. The Java code should be in a servlet or action invoked before the JSP. Use an MVC framework (Stripes, Struts, Spring MVC, etc.) to separate your Java code from your JSP code. I've used Stripes on app engine with success and pleasure.
To make sure your JSPs are valid, you can be helped by Eclipse, but you should also deploy your webapp (on the local server) and run tests to make sure every JSP compiles and runs correctly. You can automate these tests with HtmlUnit or Selenium.

how to implement sample jms, springs program in my eclipse

I'm new to jms and springs and eclipse as well. i'm trying to implement jms example using Springs in MyEclipse 7.1, and i have been referring the following url.
http://java-x.blogspot.com/2006/12/implementing-jms-with-spring-messaging.html
But Iam unable to understand how to execute the program, it contains a servlet but does not have any html or jsp page, should i create a web project for it or java application? How do i run the program.
Thanks and Best Regards.
You should create a web project to hold the servlet. A web project will have a directory for java source and a directory for web content (images, html, jsp, etc.). Make sure that you put the servlet code inside the java source directory. You will also need to register the servlet in web.xml unless it is a Java EE 5 servlet with annotations.
To run your servlet, right click on it and select Run As -> Run on Server

hosting GWT project

What do i need to upload from my gwt project to web hosting?
its just html or all project files?
Any modern Java IDE gives you an option to export a web project as a war module. If your are not using an IDE, it depends:
If you just write your code under client folder, no need to upload any .class files to the server. You don't need any Java Application server as well, and a normal HTTP server (such as Apache) would suffice. An example of such a GWT application is GWT showcase which is included in GWT download package.
If you have any server-side code under server package, then you should upload .class files (under WEB-INF/classes folder in your web modile) as well as the rest of .js, .css, .jpg/gif, .html files. In this case you need a servlet container such as Tomcat to serve your server-side code.
You'll only need to upload the html files, the css files, and your java file. Also, any other file linked to within your html files need to go in the same directory.