i have uploaded one war file in remote tomcat server.here i have to unzip the war file.here i have to run the Demo java class on my browser.how can i do????
this is the saved path of Demo.java:
/var/lib/tomcat7/webapps/Example/WEB-INF/classes/com/testprops/ws
Here i have to run these means URL http://xx.xx.xx.xxx:8080/Example/ means am getting these page successfully.please check this:http://screencast.com/t/DKZW1t9Z1
This is my Demo.java:
public class Demo {
public String customerData(){
String customerInfo = "";
int a=10;
customerInfo = customerInfo + a;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/android","androiduser","AN124@7#7");
//Find customer information where the customer ID is maximum
PreparedStatement statement = con.prepareStatement("SELECT * FROM xcart_customers");
ResultSet result = statement.executeQuery();
while(result.next()){
customerInfo = customerInfo + a + "&" + result.getString("login") + "&" + result.getString("password") + "&"+result.getString("firstname") + "&"+result.getString("email");
//Here "&"s are added to the return string. This is help to split the string in Android application
}
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return customerInfo;
}
}
How can i run the Demo.java class on my browser.please help me.
That is because you need to write a servlet that runs the code. Basically when you give a request to the above given link, then it calls
Demo.javaclass and the output is given.It is recommended to please first learn a bit basics about servlets. That should help.
So have a simple servlet like