Free JSP/Java hosting [updated: 16/03/2013]

UPDATED: 22 March 2011
               So many Java developer have question about free JSP,Servlet,Java hosting. After visiting so many site i found one perfect solution that works fine for my application. I'll give you step by step procedure to publish your site for demo. You'll find so many free hosting site but they will give you free hosting for month after you pay but for demo we need not pay from now.


Open site : http://free.hostingjava.it. Its Italian website so you won't understand language but don't worry. To understand all options of this website i divided tutorial in 4 different sections.

Section 1: How to register on http://free.hostingjava.it ?

Step 1: Register your self for free account. Fill required information to register. You must agree both conditions to processed further. I recommend you not to upload sensitive and personal database on website. This is for testing purpose only. Check out the below image for reference.


Section 2: How to manage database on http://free.hostingjava.it.

Step 1: Open Mysql from left side link and login with username and password of your account.


Step 2: Open your database from left side panel. Admin panel of MySql shown in below image.


Step 3: Create table with column you want.


Step 4: Create column with datatype you want for your table.


Step 5: Inserting data for sample application.


Section 3: How to create web application on http://free.hostingjava.it with database access?

Step 1: Get database connection link. Its available on website when you logged in user Tips and Hints section. It differ from user by user.

/*
* Its differ user by user.
* Get it from website itself.
*/
javax.sql.DataSource ds=
(javax.sql.DataSource)new javax.naming.InitialContext(). lookup("java:comp/env/jdbc/javaQuery"); 
ds.getConnection();

Step 2: Sample code to access database.

<%
import java.sql.*;
 try {
      Class.forName("com.mysql.jdbc.Driver");
      javax.sql.DataSource ds=(javax.sql.DataSource) new javax.naming.InitialContext().lookup("java:comp/env/jdbc/javaQuery");
      Connection con = ds.getConnection();
      PreparedStatement stmt = con.prepareStatement("select * from javaQueryDEMO limit 0,1");
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
 out.print(rs.getString(1));
      }
      con.close();
     } catch (Exception e) {
       e.printStackTrace();
 }
%

Section 4: How to upload file on website http://free.hostingjava.it.

Step 1: You must have FTP software to upload files.
Step 2: FTP URL : ftp://javaQuery@free.hostingjava.it/ change this URL with your username or you can get it from admin panel of the website.
Step 3: Username and password is same as register on website.
Step 4: Upload appropriate file on web directory.

12 comments :

  1. Hey !! thanxx a lot for this incredible stuff.. please tell me how to upload the database settings and files , as mine web page has to connect to the database ...

    ReplyDelete
  2. The above article is for free hosting and it don't provide database as this is for static site and to test our webpages, servlets, etc... So they are not providing the database. You have to buy the domain and space for that.

    ReplyDelete
  3. Hey .. but http://free.hostingjava.it has a sqlconsole that opens a phpmyadmin page.
    I Tried making database and even succeeded...but now i cant log in back into that... i thought if i could configre that phpmyadmin then it could also support the database... please take a look .. if anyhow i could use my database...

    ReplyDelete
  4. Use localhost as a connection URL it'll automatically connect. and id password that u have to login db.

    Connection con = DriverManager.getConnection("localhost", "username", "password");

    ReplyDelete
  5. Thanksss for this article!! But I have problem...I working on servlet and follow your steps. I have three packages (called "Clases", "Datos", and "Presentacion")...and placed each file .java in their respective folder ( WEB-INF/classes/Clases; WEB-INF/classes/Datos; WEB-INF/classes/Presentacion), but when I try to open the jsp file in the server following happens:
    org.apache.jasper.JasperException: Unable to compile class for JSP:

    An error occurred at line: 6 in the generated java file
    Only a type can be imported. Clases.LineaPedido resolves to a package

    An error occurred at line: 7 in the generated java file
    Only a type can be imported. Clases.Pedido resolves to a package

    An error occurred at line: 8 in the generated java file
    Only a type can be imported. Clases.Cliente resolves to a package

    An error occurred at line: 10 in the generated java file
    Only a type can be imported. Datos.ProductoDA resolves to a package

    An error occurred at line: 12 in the generated java file
    Only a type can be imported. Datos.ProductoDA resolves to a package

    An error occurred at line: 13 in the generated java file
    Only a type can be imported. Clases.Producto resolves to a package

    any suggestions?

    ReplyDelete
  6. Did you checked the lines of your java file described in above error like

    An error occurred at line: 6 in the generated java file
    Only a type can be imported. Clases.LineaPedido resolves to a package

    And index.jsp file must be compiled means the jsp file you upload to the server is from the web/index.jsp that is compiled file of index.jsp

    Did you uploaded web.xml file to the server??

    ReplyDelete
  7. Hi, I have a 404 problem, I don't know how configure the catalina.policy

    grant codebase "file:/home/hostingjava.it/" {
    permission java.util.PropertyPermission "*", "read";
    permission java.lang.RuntimePermission "getAttribute";
    permission java.io.FilePermission "/home/hostingjava.it//-",
    "read,write,delete";
    permission java.lang.RuntimePermission
    "accessClassInPackage.org.apache.tomcat.util.*";
    }

    ReplyDelete
  8. @jo@o you don't need to configure any file. But you must upload "web.xml" file to the server and i didn't used it much as i have my own space (Website) for java. I wrote the article for those who want to just test the code.

    File to be upload:
    JSP pages, classes , web.xml , servlet classes, library files, etc....

    ReplyDelete
  9. Hey Is this site support Java Bean ??

    I m unable to run my project in which i have used code of java bean !!!

    Plz Guide me !!!

    Thnx in Advance !!

    ReplyDelete
  10. @Gaurav i didn't used it much as i have my own space (Website) for java. I wrote the article for those who want to just test the code but i didn't tested all the things... So sorry Bro...

    ReplyDelete
  11. Hello
    I think there is only few java hosting providers that host your website for free ,you can check this directory ,it lists all java hosting providers and also some review http://javaforserver.mywebcommunity.org/

    ReplyDelete
  12. That's a great place,

    I've added it to the list I'm maintaining regarding free java hosting resources

    http://freejava.webuda.com

    ReplyDelete