Hello,
I like the look and feel of GWT but I can find out why i am getting
a
Error when invoking the pageable data service :404 <html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
<title>Error 404 NOT_FOUND</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /timesheettracking/timesheetlogin. Reason:
<pre> NOT_FOUND</pre></p><hr /><i><small>Powered by Jetty://</small>
I have spent 2 days already trying to figure it out and about to give
up. Here is my code
WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"
http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>timesheetLoginServlet</servlet-name>
<servlet-
class>com.timesheet.tmproject.server.TimeSheetLoginServiceImpl</
servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>timesheetLoginServlet</servlet-name>
<url-pattern>/TimeSheetTracking/timesheetlogin</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>TimeSheetTracking.html</welcome-file>
</welcome-file-list>
</web-app>
//TIMESHEET LOGIN SERVICE
package com.timesheet.tmproject.client;
import java.util.List;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
public interface TimeSheetLoginService extends RemoteService {
public boolean isAuthenticated(String empID, String password );
}
//TIMESHEET LOGIN SERVICE ASYNC
package com.timesheet.tmproject.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface TimeSheetLoginServiceAsync {
public void isAuthenticated(String empID, String
password ,AsyncCallback callback);
}
//TIMESHEETTRACK.JAVA
package com.timesheet.tmproject.client;
import java.util.ArrayList;
import java.util.Iterator;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SourcesTabEvents;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TabListener;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TimeSheetTracking implements EntryPoint {
VerticalPanel vpLogin = new VerticalPanel();
private Label lblLoginEmpID = new Label("Employee ID");
private TextBox txtEmpID = new TextBox();
private Label lblLoginPassword = new Label("**Password ");
private PasswordTextBox txtPassword = new PasswordTextBox();
private Button btnLogin = new Button("Login");
private String _empID;
private String _password;
final TimeSheetLoginServiceAsync timesheetLoginServlet =
(TimeSheetLoginServiceAsync) GWT
.create(TimeSheetLoginService.class);
@SuppressWarnings("deprecation")
public void onModuleLoad() {
ServiceDefTarget endpoint = (ServiceDefTarget)
timesheetLoginServlet;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() +
"timesheetlogin");
txtEmpID.setStyleName("txtTextbox");
txtPassword.setStyleName("txtTextbox");
lblLoginEmpID.setStyleName("lblLabels");
lblLoginPassword.setStyleName("lblLabels");
btnLogin.setStyleName("btnButtons");
// Create a tab panel with three items.
TabPanel panel = new TabPanel();
HorizontalPanel hpLogin = new HorizontalPanel();
hpLogin.add(lblLoginEmpID);
hpLogin.add(txtEmpID);
vpLogin.add(hpLogin);
HorizontalPanel hpLogin2 = new HorizontalPanel();
hpLogin2.add(lblLoginPassword);
hpLogin2.add(txtPassword);
hpLogin2.add(btnLogin);
vpLogin.add(hpLogin2);
panel.add(vpLogin, "Login");
panel.setWidth("100%");
panel.selectTab(0);
// Hook up a tab listener to do something when the user selects a
tab.
panel.addTabListener(new TabListener() {
public void onTabSelected(SourcesTabEvents sender, int
tabIndex) {
// Let the user know what they just did.
}
public boolean onBeforeTabSelected(SourcesTabEvents sender,
int tabIndex) {
// Just for fun, let's disallow selection of 'panel'.
// if (tabIndex == 1)
// return false;
return true;
}
});
// Add it to the root panel.
panel.setSize("500px", "250px");
panel.addStyleName("table-center");
RootPanel.get().add(panel);
btnLogin.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
getLoginResult();
}
});
}
private void getLoginResult() {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
_empID = txtEmpID.toString();
_password = txtPassword.toString();
}
public void onFailure(Throwable caught) {
Window.alert("Error when invoking the pageable data service :" +
caught.getMessage());
}
};
timesheetLoginServlet.isAuthenticated(txtEmpID.toString(),txtPassword.toString(),
callback);
}
}
//TIMESHEETLOGINSERVICEIMPL
package com.timesheet.tmproject.server;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.timesheet.tmproject.client.TimeSheetLoginService;
public class TimeSheetLoginServiceImpl extends RemoteServiceServlet
implements TimeSheetLoginService {
private boolean isAuthentic = false;
private String _empID;
private String _password;
public TimeSheetLoginServiceImpl() {
super();
Authenticate();
}
public boolean Authenticate()
{
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver")
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/
timex", "root", "");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT employeeid, password FROM
employee WHERE " +
"employeeeID="+_empID+" AND password =
"+_password);
if(rs == null)
{
isAuthentic = false;
}
else
{
isAuthentic = true;
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally{
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return isAuthentic;
}
public boolean isAuthenticated(String empID, String password) {
_empID = empID;
_password = password;
return Authenticate();
}
}
Please, if you see anything here that may be causing this error, I
would appreciate to post a note. I am new at GWT and I am very
frustrated as I have spent too much time on this task...
Thank you