Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java Servlets

Options
  • 23-01-2002 10:29pm
    #1
    Closed Accounts Posts: 4


    While versed in Java I am at a loss at to how to begin with Servlet technology. JSDK2.1, JSWDK1.0.1, JDK1.2.2 are some of the programmes I have downloaded from javasoft.com but Im not sure which is the correct one. At present hosting an actually server accessable on the net is not a priority. I merely want an environment to test the servlets or rather servlet embedded pages I make. Is it possible to compile and test servlets through Borland's Jbuilder? All Advice Appreciated.


Comments

  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Ok what you have been downloading are Java Development Kits that contain general APIs for creating various types of software (applets, applications etc). But you want to use Servlets.

    Java at this point can be divided up in to @ least 3 sections that govern the underlying APIs. Them being
    1. J2SE (Standard APIs)
    2. J2EE (Enterprise APIs)
    3. J2ME (Wireless/Embedded Client APIs)

    Enterprise computing involves writing software that runs on the server side. That is often distibuted accross several physical or logical tiers. In your case, you need Servlets. Servlets (& JSPs) let you create server-side web applications. So this is where you have the connection between Servlets/JSPs and J2EE. Now let's say for example you only need the Servlet APIs and not the whole J2EE group of APIs. You simply go to java.sun.com and download what you want.

    I have already found the page where you can download the latest Servlet API
    http://java.sun.com/products/servlet/download.html

    Once downloaded, you will find a file called servlet.jar. Append this file to the CLASSPATH used by your IDE. You will now be able to write/compile servlets. But to be honest I never liked using JBuilder for anything other than GUI based applications. I simply use an ASCII based text editor and the DOS command line tools made available by your JDKs.

    As regards testing them on your machine. Don't test them in JBuilder (you can, but it's crap). Instead download Tomcat from the Apache group (actually I think you can get this from Sun also). It's a free (open source) HTTP server, with a JSP & Servlet container. It's quickly becomming and industry standard server, and is configured using XML (very nice ;))

    I hope this info helps, if not, feel free to fling out some more questions ;)

    ;-phobos-)


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    You also forgot PJEE (Personal Java)

    Btw, Forte the free IDE for java delevopment comes with the tomcat server built in so you can check your stuff.


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Originally posted by Hobbes
    You also forgot PJEE (Personal Java)

    I was aware that Personal Java was part of the J2ME platform, that governed embedded devices. Why would PJ have an EE associated with it. Since Personal Java is used to write client ware.

    If you check out http://wireless.java.sun.com/
    you will see that PJ is part of the J2ME suite.

    ;-phobos-)
    PS: AFAIK this should be my 500th post. God I remember when I just a wee Cool Newbie ;)


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    now youre a freak, muhahahahaha


  • Registered Users Posts: 1,500 ✭✭✭viking


    Setting up the JBuilder environment for Tomcat 3.2.X
    Create a new project. (This should be away from the jakarta-tomcat folder so that the .jpr file will not be deleted if you update the version of Tomcat.)

    Project | Project Properties…
    Paths page | Required Libraries tab
    Add…
    New…
    Enter name of library (e.g. Tomcat 3.2.1)
    Select location (User Home or JBuilder)
    Add… (first navigate to jakarta-tomcat/lib)
    ant.jar
    jasper.jar
    servlet.jar
    xml.jar
    webserver.jar
    Select the new library (by the name you gave it above) and click Edit…
    Click the Source tab and set the source path to jakarta-tomcat/src
    Click OK to close the Configure Libraries dialog.
    Save these project properties by selecting OK to close the Project Properties dialog.

    Running Tomcat
    To run Tomcat, we need to set the default Run configuration as detailed below. Essentially, this involves doing two things:
    · indicate the main class
    · set any necessary VM parameters (as would be passed to the java launcher on the command line)
    Starting the debugger in JBuilder 4 using the default compiler setting can be extremely slow. If you add "-classic" in the VM parameters field, this will cause the VM to not use the HotSpot compiler, and will speed things up dramatically.
    Tomcat uses the tomcat.home system property, and requires it to be set to the location of the Tomcat installation. System properties are set with the -D command line switch so we need to add the VM parameter: "-Dtomcat.home=d:/jakarta-tomcat". The "-classic" option must come before the "-Dtomcat.home=d:/jakarta-tomcat".

    Setting the Run configuration options
    Project | Project Properties…
    Run tab
    Set Main class to org.apache.tomcat.startup.Tomcat
    In the VM parameters box, enter -classic -Dtomcat.home=d:/jakarta-tomcat
    Click OK to close the Project Properties dialog.

    To test the installation,
    File | Save All.
    Run Project.
    You are now running Tomcat with the default configuration. You should see the message "Starting tomcat. Check logs/tomcat.log for error messages".
    Two directories are created, logs and work, off the working directory.

    Using Tomcat in JBuilder
    To use Tomcat, simply add the Tomcat library to your project and set the Run configuration options, as indicated previously.

    There's nothing special you need to do to debug servlets and JavaBeans called from JSP files, you simply choose Debug Project instead of Run Project. Tomcat's default configuration includes an invoker servlet, and the classpath for your project is included when you start Tomcat, so it can find the classes.

    To debug JSPs, you need to put the JSP page where the Web server can find it. For the default Tomcat configuration, you can use the default context at
    d:/jakarta-tomcat/webapps/ROOT, which you would then access with a URL like http://localhost:8080/whatever.jsp.

    viking


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Does JBuilder 5 come with Tomcat?


  • Registered Users Posts: 1,500 ✭✭✭viking


    Originally posted by Evil Phil
    Does JBuilder 5 come with Tomcat?

    Nope, you need to download it from the Apache website

    viking


Advertisement