Compiling a servlet with utility class

Hello,
I am having trouble compiling a servlet that uses a utility class.
The compiler doesn't seem to recognize the utility class for some reason.
my classpath is set to:
.;C:\ServletDevel;C:\Program Files\Apache Software Foundation\common\lib\servlet-api.jar
the error:
Cannot find symbol: ServletUtilities
the servlet code:
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** test the use of packages and utilities on the server */
public class helloservlet3 extends HttpServlet {
public void doGet(HttpServletRequest request,
               HttpServletResponse response)
               throws ServletException, IOException {
     response.setContentType("text/html");
     PrintWriter out = response.getWriter();
     String title = "Hello (3)";
     out.println(ServletUtilities.headWithTitle(title) +
          "<body bgcolor=\"#FDF5E6\">\n" +
          "<h1>" + title + "</h1>\n" +
          "</body></html>");
the utility class:
package coreservlets;
import javax.servlet.*;
import javax.servlet.http.*;
/** time saving static methods */
public class ServletUtilities {
     public final static String docType =
     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
     "Transitional//EN\">";
public static String headWithTitle(String title){
return (docType + "\n" + "<html>\n" +
          "<head><title>" + title + "</title></head>\n");
any help wouldbe greatly appreciated.

Nope still getting an error
helloservlet3.java:17:cannot find symbol
symbol : class ServletUtilities
location: package coreservlets
out.println(coreservlets.ServletUtilities.headWithTitle(title) +
thanks for the help, i'll keep on trying to figure it out.

Similar Messages

  • Compiling Java Servlet with Depricated Methods

    I have a problem of compiling Java servlets that contain depricated methods. If you compile against modern version of servlet.jar I see depricated methods error messages and if I use a very old servlet.jar it cannot find newer methods. What is is the best solution in this case?
    Thank you,
    Boris.

    The best thing to do would be compile your code with the -depreciated option to find which methods have been depreciated and the refactor your code to remove them.
    The next best thing is to ignore the messages (they are warnings not errors) and your code should still work

  • Compiling servlet with helper class

    Hello,
    I have to write a very large number of database queries and huge amount of code so I decided to make each helper *.class file for each table.
    Now I have a main servlet that should instantiate each of these helper classes and conduct DB operations:
    //Servlet code
    RescardreservationTable rv = new RescardreservationTable();
    rv.insertInfo();
    RescardPassengerTable rp = new RescardPassengerTable();
    rp.insertInfo();RescardreservationTable.class
    //does DB opsMy problem is that when I try to compile servlet, I get
    insert_data.java:172: cannot find symbol
    symbol : class RescardreservationTable
    location: class insert_data
    RescardreservationTable rv = new RescardreservationTable();
    Could somebody please tell me how I can make servlet locate my java classes that it has to use?
    Thanks,
    Victor.
    Edited by: vic_sk on Dec 9, 2008 9:29 AM

    Ok, looks like it's solved. Just forcing the compiler with -classpath to look for the required class file.

  • B32 compiler bug: varargs with anonymous class

    Environment
    SunOS bart 5.10 s10_48 i86pc i386 i86pc Solaris
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
    Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)
    javac 1.5.0-beta
    Javac command produces NullPointerException
    javac -source 1.5 -target 1.5 Quick.java (source follows)
    Description
    The problem seems to be use of a varargs constructor while defining
    an anonymous class. Work around is for caller to manually box the
    (varargs) into an array, bypassing convenience of varargs support.
    class Quick
      Quick() {
        Fox fox1 = new Fox(1)                        {}; // compiles
        Fox fox2 = new Fox(new String[] { "hello" }) {}; // compiles
        // NullPointerException not thrown when following 4 lines are
        // commented out.
        Fox fox3 = new Fox(null)            {}; // compiles, but ambiguous?
        Fox fox4 = new Fox()                {}; // javac NullPointerException
        Fox fox5 = new Fox("hello")         {}; // javac NullPointerException
        Fox fox6 = new Fox("hello", "bye")  {}; // javac NullPointerException
    class Fox
      Fox(int a) {
        _keys = new String[0];
      Fox(String... keys) {
        _keys = keys;
      final String[] _keys;
    }

    reported as 4986231

  • Trouble with Ford class

    I created this abstract class ...
    public abstract class v8Engine {
      public String start;
      public boolean getInspectionResults;
    }... Then I extended it like this ...
    public class FordWindsorV8  extends v8Engine {
      private static int rebuildCount;
      private static final boolean passInspection = false;
      private static final String aquireLocation = "junkyard";
      public String start() {
        return("useless");
      public void reBuild() {
        rebuildCount++;
      public boolean getInspectionResults() {
        return(passInspection);
      public String aquireEngineResults() {
        return(aquireLocation);
      public int getRebuildCount() {
        return( rebuildCount );
      }... Finally I tried to run it after compiling it all, with this class:
    public class runV8Engine {
        FordWindsorV8 fv8 = new FordWindsorV8();
        System.out.println("Where was engine obtained? ... "+fv8.aquireEngineResults());
        fv8.reBuild();
        System.out.println("Start results: "+fv8.start());
        System.out.println("Pass MV inspection? ... "+fv8.getInspectionResults());
        fv8.reBuild();
        System.out.println("Start results: "+fv8.start());
        fv8.reBuild();
        System.out.println("Start results: "+fv8.start());
        fv8.reBuild();
        System.out.println("Engine was rebuilt how many times? ... "+fv8.getRebuildCount());
        System.out.println("Start results: "+fv8.start());
        System.out.println("Pass MV inspection? ... "+fv8.getInspectionResults());
    }... But all it does is basically nothing. Why?

    Like this ;-)
    public class runV8Engine {
    public static void main(String[] argv) {
    FordWindsorV8 fv8 = new FordWindsorV8();
    System.out.println("Where was engine obtained? ... "+fv8.aquireEngineResults());
    fv8.reBuild();
    System.out.println("Start results: "+fv8.start());
    System.out.println("Pass MV inspection? ... "+fv8.getInspectionResults());
    fv8.reBuild();
    System.out.println("Start results: "+fv8.start());
    fv8.reBuild();
    System.out.println("Start results: "+fv8.start());
    fv8.reBuild();
    System.out.println("Engine was rebuilt how many times? ... "+fv8.getRebuildCount());
    System.out.println("Start results: "+fv8.start());
    System.out.println("Pass MV inspection? ... "+fv8.getInspectionResults());

  • Is there a Java utility class to help with data management in a desktop UI?

    Is there a Java utility class to help with data management in a desktop UI?
    I am writing a UI to configure a network device that will be connected to the serial port of the computer while it is being configured. There is no web server or database for my application. The UI has a large number of fields (50+) spread across 16 tabs. I will write the UI in Java FX. It should run inside the browser when launched, and issue commands to the network device through the serial port. A UI has several input fields spread across tabs and one single Submit button. If a field is edited, and the submit button clicked, it issues a command and sends the new datum to the device, retrieves current value and any errors. so if input field has bad data, it is indicated for example, the field has a red border.
    Is there a standard design pattern or Java utility class to accomplish the frequently encountered, 'generic' parts of this scenario? lazy loading, submitting only what fields changed, displaying what fields have errors etc. (I dont want to reinvent the wheel if it is already there). Otherwise I can write such a class and share it back here if it is useful.
    someone recommended JGoodies Bindings for Swing - will this work well and in FX?

    Many thanks for the reply.
    In the servlet create an Arraylist and in th efor
    loop put the insances of the csqabean in this
    ArrayList. Exit the for loop and then add the
    ArrayList as an attribute to the session.I am making the use of Vector and did the same thing as u mentioned.I am using scriplets...
    >
    In the jsp retrieve the array list from the session
    and in a for loop step through the ArrayList
    retrieving each CourseSectionQABean and displaying.
    You can do this in a scriptlet but should also check
    out the jstl tags.I am able to remove this problem.Thanks again for the suggestion.
    AS

  • Trouble compiling servlets with J2SE 5

    Hello,
    I've been using Sun 1 Studio CE, and more recently, Netbeans 3.6, with J2SE 1.4.2. I have some basic swing applets and servlets that I wrote for my business' web site.
    I recently downloaded and installed the new software bundle containing Netbeans 4.0 and J2SE 1.5. When I try to compile my servlets, I get a compiler error that packages javax.servlet.* and javax.servlet.http.* do not exist.
    I reinstalled J2SE 1.4.2 and Netbeans 3.6 and the servlets compile fine.
    Why is JDK 5 not able to find these packages? My understanding is that they're part of the Java Servlet API, which I never explicitly downloaded previously. Is that the piece of the puzzle that I'm missing? Please help!
    Thanks

    Thanks for your response...
    What is interesting is that I never explicitly installed the Servlet API. Out of curiosity, I searched my computer for servlet*.jar and came up with 13 files including:
    servlet-2.2.jar
    servlet-2.3.jar
    servlet-api-2.4.jar
    These were located in subdirectories under Netbeans 3.6 and Tomcat 5.0.19. Therefore, I'm assuming that when I downloaded the JDK 1.4.2/Netbeans 3.6 bundle from the Java site, the Servlet API must have been part of the bundle.
    ****Let me check something...***
    I've just done the same search for servlet*.jar on my test PC, which has the Netbeans 4.0/JDK 5 bundle installed. The same files exist, in the same locations(almost the same, anyway; the Tomcat and Netbeans 4 directory structures are a little different).
    Both software bundles contain the same files, yet 1.4.2 compiles without any problems or additional configuration. In other words, I reinstalled the old 1.4.2/ Netbeans 3.6 bundle, took my existing source code, and started compiling.
    Any ideas why the same isn't true for JDK 5/Netbeans 4? I know there are changes to the way Netbeans 4.0 deals with Class Paths, but I thought that was for the classes I've written. Shouldn't the compiler be able to find the servlet API, since it bundled/installed with everything else?
    Thanks

  • Can I compiler servlet with java compiler?

    Can I compiler servlet with java compiler?
    Here is an example of it:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class HelloWorldServlet extends HttpServlet
              protected void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException , IOException
                        response.setContentType("text/html");
                        PrintWriter out = response.getWriter();
                        StringBuffer sb = new StringBuffer();
                        sb.append("<html><body><h1>");
                        sb.append("Hello World");
                        sb.append("</h1></body></html>");
                        out.print(sb.toString());
                        out.close();
         }

    Can I compiler servlet with java compiler?
    yes.
    just include the correct jarfiles in your classpath.

  • Help compiling BookStore  SERVLETS tutorial classes

    I am new to Java. Please be patient with my errors. I need help with compiling the servlets given as part of the SERVLET tutorial. I have previously installed JDK1.3.1.01. I have also downloaded the JSDK2.1 as part of the tutorial. As part of the tutorial several servlet classes were provided. Almost all of them have these import statements.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    However, the javac is unable to compile the classes. I think it is because javax.servlet is installed under /root/jsdk and JDK is installed under /usr/java/jdk1.3/bin. I can find the javax directory under /root/jsdk but not under /usr/java. I tried giving the classpath option to javac as:
    javac -classpath /root/jsdk BookStoreServlet.java
    But it did not work.
    I believe once the servlet classes are compiled it will be possible to view them from the JSDK browser. I was able to successfully start the jsdk browser with startserver script given with the distribution. And the example SnoopServlet worked fine.
    In summary, I believe the authors of the tutorial left out the details of compiling the classes and viewing from browser. I could be wrong about it.
    I will appreciate any help from the users of the tutorial and anyone who knows servlets.
    Many thanks.
    Murthy

    i found this info on how to set the classpath in linux
    http://java.sun.com/products/jdk/1.2/docs/tooldocs/sola
    is/classpath-linux.htmlThanks imp-cat. I could compile the BookStoreServlet.java into its corresponding class. I get the following error when I try to run it. What should I do? Thanks. Regards. Murthy
    java BookStoreServlet
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)

  • How to compile servlet with Edit Plus?

    Hi
    I am writing a Java servlet in EditPlus and am wondering how to include the servlet.jar file so that EditPlus knows where the javax.servlet.*, etc classes are. I suppose this is an EditPlus specific question so sorry about that but I didn't know who else to ask other than EditPlus themselves of course and I think I have tried that once.
    I have read replies on this forum about changing the classpath but I dont think that that is what I need to do here and if it is I dont know what I should be writing as I am not using the jdk.
    If anyone can help me at all I would be very grateful.
    Thanks

    Yes, I have also compiled Java files from EditPlus. Using the facilities for configuring 'User Tools' in EditPlus.
    EditPlus runts programs(javac in the current context) in a separate environment(separate DOS command).
    I just compiled, from EditPlus, some Java file of mine that uses something from the servlet API. It compiled just fine. I did not do any classpath or other setup on classpath lines inside EditPlus. I guess, EditPlus inherits the existing CLASSPATH(all environment settings in fact) setting from your environment and thereafter aslo passes it along to the separate command prompt it opens to run user configured tools to run.

  • Error in compiling: file javax\servlet\jsp\PageContext.class not found

    Hi,
    i'm getting an error when I'm trying to compile an java file. The error is as follows:
    cannot access javax.servlet.jsp.PageContext
    file javax\servlet\jsp\PageContext.class not found
    Isn't the javax package included in jdk? I've installed jdk 1.3.1_03 and j2re1.4.0_02. Shouldn't this PageContext.class be automatically loaded when i've installed jdk?
    I'm getting desperated! I've tried almost everything: i've changed the classpath, moved the directory of the java file I'm trying to compile over and over but i'm getting no success!
    Any help is very welcome!
    Thankx,
    Nuno.

    hmmm... i had a look and it seems that what you are trying to "import" is actually in a package... instead of import try:
    package javax.servlet.jsp;you may need to go download this "package" and complile it in the directory you are working in.
    my advice: try the above statement (which does compile for me), if it doesn't work, you will need to find the source code for this package and compile it just like you do any other source code.
    hope this helps.

  • Shared utility class file among servlets and Ejb

    I have the following context:
    XXX.war:
    WEB-INF\
    Jsp files
    WEB-INF\classes\
    WEB-INF\lib\
    WEB-INF\web.xml
    WEB-INF\weblogic.xml
    YYY.jar
    META-INF\
    Class files
    META-INF\ejb-jar.xml
    META-INF\weblogic-ejb-jar.xml
    In XXX/WEB-INF/classes/…/Util.class
    In YYY/util.class
    How can I share Util.class between both XXX and YYY?
    Cheers,

    If you are on 8.1 check out
    http://e-docs.bea.com/wls/docs81/programming/classloading.html#1069420
    The larger document talks about how classloading works in Weblogic
    Dave
    <mehdi valizadeh> wrote in message news:[email protected]..
    I have the following context:
    XXX.war:
    WEB-INF\
    Jsp files
    WEB-INF\classes\
    WEB-INF\lib\
    WEB-INF\web.xml
    WEB-INF\weblogic.xml
    YYY.jar
    META-INF\
    Class files
    META-INF\ejb-jar.xml
    META-INF\weblogic-ejb-jar.xml
    In XXX/WEB-INF/classes/???/Util.class
    In YYY/util.class
    How can I share Util.class between both XXX and YYY?
    Cheers,

  • Utility Classes in EAR

    Hello,
    Can someone tell me where I should put utility classes in an .ear file when
    they are being used by both the EJBs (in the .jar file) and the web app (in
    the .war file). I tried just putting them in the root of the .ear file but
    WL 6.0 still couldn't find them. Is there such thing as META-INF/lib?
    Thanks in advance,
    Rob Lewis

    I remember that somebody else reported this problem - when the utility classes are
    in the ejb-jar servlets do work, but JSPs fail to compile - that sounded like a WLS bug.
    Here is the description of 6.0 classloading:
    http://e-docs.bea.com/wls/docs60/programming/topics.html#1037589
    Rob Lewis <[email protected]> wrote:
    This doesn't appear to be the case. I have an EAR with a JAR and WAR in it.
    I removed the utility classes from the WAR that were repeated in the JAR.
    Then the JSPs failed to find those classes. JBoss lets you put utility
    classes in a JAR in the EAR and then set 'Class-Path' in the manifest.mf to
    point to it but this also didn't work for me in WL6.
    I'm at a loss.
    Rob
    "Cameron Purdy" <[email protected]> wrote in message
    news:[email protected]..
    I think you can put them in either the JAR or the WAR and it willwork --
    wl6 seems to use a single classloader for the entire ear.
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Rob Lewis" <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    Can someone tell me where I should put utility classes in an .ear filewhen
    they are being used by both the EJBs (in the .jar file) and the web app(in
    the .war file). I tried just putting them in the root of the .ear filebut
    WL 6.0 still couldn't find them. Is there such thing as META-INF/lib?
    Thanks in advance,
    Rob Lewis
    Dimitri

  • Utility classes in WebService EAR

    What would be the best way to include utility classes in the Web Service EAR?
    Thanks in advance

    I remember that somebody else reported this problem - when the utility classes are
    in the ejb-jar servlets do work, but JSPs fail to compile - that sounded like a WLS bug.
    Here is the description of 6.0 classloading:
    http://e-docs.bea.com/wls/docs60/programming/topics.html#1037589
    Rob Lewis <[email protected]> wrote:
    This doesn't appear to be the case. I have an EAR with a JAR and WAR in it.
    I removed the utility classes from the WAR that were repeated in the JAR.
    Then the JSPs failed to find those classes. JBoss lets you put utility
    classes in a JAR in the EAR and then set 'Class-Path' in the manifest.mf to
    point to it but this also didn't work for me in WL6.
    I'm at a loss.
    Rob
    "Cameron Purdy" <[email protected]> wrote in message
    news:[email protected]..
    I think you can put them in either the JAR or the WAR and it willwork --
    wl6 seems to use a single classloader for the entire ear.
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Rob Lewis" <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    Can someone tell me where I should put utility classes in an .ear filewhen
    they are being used by both the EJBs (in the .jar file) and the web app(in
    the .war file). I tried just putting them in the root of the .ear filebut
    WL 6.0 still couldn't find them. Is there such thing as META-INF/lib?
    Thanks in advance,
    Rob Lewis
    Dimitri

  • Re: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't forget about the regular expression potential

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

Maybe you are looking for