Java
  Home arrow Java arrow Page 7 - Slapping Together A JSP Development En...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Slapping Together A JSP Development Environment
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2001-03-05

    Table of Contents:
  • Slapping Together A JSP Development Environment
  • Essential Software
  • One Tomcat, Standing Alone
  • Connecting The Dots
  • Same Story, Different OS
  • Putting It In Context
  • Making The Grade

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Slapping Together A JSP Development Environment - Making The Grade


    (Page 7 of 7 )

    If you plan to use JSP to communicate with a database using a JDBC connection, there are a couple of additional things you need to do.

    First, get yourself a copy of the mm.mySQL module from http://www.worldserver.com/mm.mysql/ or http://mmmysql.sourceforge.net/ - this is required to communicate with the database. Extract the file "mysql.jar" from the archive, and place it in your JDK's LIB/ folder.

    Next, add the location of this file to the CLASSPATH variable. On Windows, use

    C:\>SET CLASSPATH=%CLASSPATH%;C:\JDK\LIB\MYSQL.JAR

    and on Linux, use

    $ CLASSPATH=$CLASSPATH:/usr/local/jdk/lib/mysql.jar; export CLASSPATH

    Pop open your favourite text editor and create the following JSP file:

    <html> <head> </head> <%@ page language="java" import="java.sql.*" %> <body> <% Class.forName("org.gjt.mm.mysql.Driver"); //assume database "test", user "root", password "" // change this as per your requirements Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password= "); Statement stmt = myConn.createStatement(); // assume you have a "grades" table with // grades is various subjects and student names // change this as per your requirements String query = "select * from grades where literature > 90"; ResultSet myResultSet = stmt.executeQuery(query); if (myResultSet != null) { while (myResultSet.next()) { // specify the field name String name = myResultSet.getString("name"); %> <%= name %> <br> <% } } stmt.close(); myConn.close(); %> </body> </html>

    This is a simple JSP file to connect to a database, run a query and return the results. Remember to modify the database name, user details and query in the example above before proceeding.

    Finally, start up Tomcat, Apache and mySQL. Point your browser to the file you just created - say, http://localhost/examples/jsp/query.jsp and JSP should display the results of your query.

    And that's it. You now know how to set up a JSP development environment with minimum fuss and effort. Now get out there and show those kids how the pros do it!
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    JAVA ARTICLES

    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT