Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

Friday

Create & Run java server page(jsp) in IDE

0 comments
how to create jsp- Dynamic web application in Eclipse or Netbeans IDE
step-1
            File - New WebApplication
               Create a new web application  & name it.
 
to create jsp dynamic web application





                    click finish proceed to next step
 Step-2
          Right click the Web application from project Hierarchy  in right side
                 -select New -> JSP File

           <%  out.println("Hello - Pradeesh");   %>

Saturday

Servlets Connection with Mysql using JDBC

0 comments
   How to connect servlets with mysql?.Servlet program to connect to mysql database using jdbc Driver in Eclipse

If you have problem in executing servlet code, see this tutorial.


Import external jar files
  •            javax.servlet-api-3.0.1.jar
  •            mysql connector / J
To know how to import external jar to project, go here (step 5).


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.*;
import java.sql.*;

@WebServlet("/dbconnect")

public class dbconnect extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
try
{

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

String URL = "jdbc:mysql://localhost:3306/mysql";
Connection connection = null;
// Load JBBC driver "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(URL, "root", "v");

if(!connection.isClosed())
    out.println("Successfully connected to " + "MySQL server using TCP/IP...");

else
    out.println("No connection");

}

catch(Exception excp)
{
excp.printStackTrace();
}

}}





java servlet
Hope you already configured webserver (I ve tomcat7) which is needed to execute Dynamic web projects ....if not go here .

Related post :


   servlet program to get html form data
 
    Servlet with doget method

How to create servlets in Eclipse

0 comments
   How to write & execute servlets code in eclipse ,Netbeans IDE. Don't confuse with web.xml file, eclipse can automatically generate it.Develop java servlets with tomcat.

Now, Let us start with simple Hello world program in servlets .

1. File-> New ->  Dynamic web project
Name the project as Helloworld.

2. Click next, you will get a window as follow  there check in the option Generate web.xml.


Thursday

Install External Browser Firefox,Chrome in Eclipse

0 comments
External Browser Installation in  Eclipse IDE. Add Firefox, Google Chrome, Safari as default browser  in Eclipse & Netbeans IDE.Configure external browser in Eclipse.

Download Eclipse, if you dont have one.

To set external browser as default in Eclipes
Steps to do :

     1.  Open Eclipse
                Windows -> Preferences
 
     2. Select General -> Web Browser  (like showed in the following image)

Install External Browser (Firefox,Chrome) in Eclipse

     3. Select "use external web browser "
     4. Click "New"  button to add external browser of your choice.
  
                   Name = Firefox / Chrome 
                  
              Location = /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (For Mac)
                                                           (or for Linux)
                Location =  usr/bin/firefox           (for Ubuntu)
     
               Parameters = "%URL%"


      Now you can run your web project both in internal & external browser.No.of External browser can be added to Eclipse.
      You need a server configured properly to run web projects.
       

   Related post: 


         
        

Sunday

How to Install Apache Tomcat 7 in Eclipse -Linux

0 comments
configure  Apache Tomcat in eclipse 
How to Install Apache Tomcat web server
       Download & Install Eclipse (Java EE) , a Complete version.
      As a pre-requirement Java should be installed in your system , either OpenJDK or Sun JDK.

 Check your java version in ubuntu
                $      java -version

How to Setup Apache Tomcat in Eclipse 

 Let us Install Tomcat Now 
     I tried this  in Indigo & Juno , its work perfectly
     
         1.    Open Eclipse
                  File -> New -> Other

Don't Forget To Join US Our Community
×
blogger