JSP Newbie

Hi,
I want to know when we include this statement
import java.sql.*;
import java.io.*;
in our scriplet...Where does this statement look for the class file?
is it in C:\jdk1.3.1_04 or in one of the classes file in Tomcat folder?

Hi,
I want to know when we include this statement
import java.sql.*;
import java.io.*;
in our scriplet...Where does this statement look for
the class file?
is it in C:\jdk1.3.1_04 or in one of the classes file
in Tomcat folder?
=======The standard classes will be looked
in the JDK installation directory..
if u wannat import ur own classes, put 'em under the /classes directory in Tomcat(or any Webserver) and use the normal import statement
hope this helps!
javedpm

Similar Messages

  • Jsp newbie having trouble using JSP's with Jdev 10.1.3

    Hi,
    Have been bashing my head for about two hours with this, if anyone can help will substantially improve my life.
    First off apologies if question is stupid or obvious I am a jsp newbie.
    Have been experimenting with using the Jsp Taglibrary for tabbed panes in a browser.
    http://www.ditchnet.org/tabs/
    I have followed all the installation instructions but in JDeveloper when I build I get the message
    Error(18,2): method setJspContext(javax.servlet.jsp.PageContext) not found in class org.ditchnet.jsp.taglib.tabs.handler.TabConfigTag
    Any idea what jar file I'm missing.
    I'm a bit lost, thanks

    Arrrrrrrrgh,
    Sorted my problem.
    Rebuilt project, works fine now, no idea what was going on (just generally!).
    Thanks for input Shay
    Mark

  • [JSP/Newbie]: howto write my own jsp:include tag?

    Hi folks,
    I'm trying to write a replacement tag for <jsp:include> (which shall later decide upon its context what to include..), i.e. I want to include another JSP from within a tag.
    Unfortunately right now my best bet does not allow to control the position of the included JSPs output in my output stream - it prints directly :-((
    // index.jsp is my startpage:
    <%@ taglib uri="/cistags" prefix="cis" %>
    index.jsp START:
    <cis:include file="/theincludefile.jsp" />
    index.jsp ENDE
    // theincludefile.jsp is the included file
    -->INCLUDEFILE<--
    // include.java is my current idea to approach this:
    public class include extends TagSupport {
    private String jspName;
    public void setFile(String name) {
    this.jspName = name;
    public int doEndTag() {
    HttpServletRequest request =
    (HttpServletRequest) pageContext.getRequest() ;
    HttpServletResponse response =
    (HttpServletResponse) pageContext.getResponse() ;
    try {
    request.getRequestDispatcher(
    response.encodeURL(jspName)).include(request,response) ;
    catch (Exception e) { }
    return EVAL_PAGE;
    the result expected is:
    index.jsp START:
    -->INCLUDEFILE<--
    index.jsp ENDE
    but instead I receive:
    -->INCLUDEFILE<--
    index.jsp START:
    index.jsp ENDE
    So how can I get hold of the ouput generated by the JSP I'm calling through RequestDispatcher.include so that I can rewrite it into my own output stream here?
    Is someone out there able to point me into the right direction?
    Ingo
    [email protected]

    check this article out
    http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jspweb.html

  • JSP Newbie setup question

    I installed Tomcat 4.0.3 and I had IIS running on my Win2k system. I thought I could make JSP work using IIS but I read somewhere that you have to make some modifications to get it to work. Then I realized that I had Apache 1.3 installed on my system. I know that Apache is running ok because I can successfully get to the default home page. However, after installing TomCat, the instructions tell you to browse http://localhost:8080 to get to the TomCat default page but I get a page not found error. Any ideas?

    After looking at it further, your right, the Tomcat server didn't start. I thought it was running but it is not. I run the startup.bat file and it launches a window but it closes too quick to show me the error msg. I tried launching the shutdown command anyway and got this for an error:
    C:\Jakarta\jakarta-tomcat-4.0.3\bin>shutdown
    Using CATALINA_BASE: C:\Jakarta\jakarta-tomcat-4.0.3\
    Using CATALINA_HOME: C:\Jakarta\jakarta-tomcat-4.0.3\
    Using CATALINA_TMPDIR: C:\Jakarta\jakarta-tomcat-4.0.3\\temp
    Using JAVA_HOME: C:\j2sdk1.4.0_01\
    Exception during startup processing
    java.lang.ClassNotFoundException: org.apache.catalina.startup.Catalina
    at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardC
    sLoader.java:1127)
    at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardC
    sLoader.java:992)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:218)

  • JSP newbie: My first JavaBean

    Hey guys. This is my first time with JSP, and I'm trying to create a JavaBean. I seem to be getting an error when I try to set up the following:
    I have a folder called "test" which is the root of my app. Under this directory, I have a folder called "WEB-INF", then a folder called "classes" then the folder called "mathy". Under "mathy" I have a the java file called average.java along with the compiled class file.
    The code for average.java is as follows:
    package mathy;
    import java.io.Serializable;
    public class average implements Serializable {
    private double total = 0;
    public average(double n1, double n2, double n3) {
    total = n1 + n2 + n3;
    total = total / 3;
    public double getAverage() {
    return total;
    then under the original "test" folder, I have a jsp page called "exp-1.jsp" with the following code:
    <% mathy.average av1 = new mathy.average(34.4, 56.1, 694.3); %>
    Now, I'm not trying to execute any methods, just trying to see if a bean can be made. But now luck. Can anyone help? Thanks, I really appreciate it.
    I get the following error by the way with Tomcat Version 4.0-b5:
    A Servlet Exception Has Occurred
    org.apache.jasper.JasperException: Unable to compile class for JSPC:\jakarta-tomcat-4.0-b5\work\localhost\test\exp_0002d4_jsp.java:55: Class mathy.average not found.
    mathy.average av1 = new mathy.average(34.4, 56.1, 694.3);
    ^
    C:\jakarta-tomcat-4.0-b5\work\localhost\test\exp_0002d4_jsp.java:55: Class mathy.average not found.
    mathy.average av1 = new mathy.average(34.4, 56.1, 694.3);
    ^
    2 errors

    it's fine to put package mathy. I use this method all the time. After that, you have to put this line at the top of your jsp page <jsp:useBean id="name_of_bean" scope="application" class="mathy.NameOfYourClass" />.
    If you can't have your last modified jsp file, try the following steps:
    1) Shutdown Tomcat and Start Tomcat again.
    2) Delete your root directory on tomcat\work\your_root_directory
    3) Close your IDE and open again.
    Any one of the steps above will be abled to solve your problems. Otherwise, just let me know.
    Good Luck.

  • JSP newbie (from PHP)

    Hello!
    I want to re-write my php code into servlets or jsp.
    so, how do I do an include directive to include headers and footers such as in php with include("header.php") ?
    jason

    <jsp:include page="header.jsp" />

  • Jsp newbie, please help about @include

    I am new to JSP.
    I have two jsp files, say , jsp1 and jsp2.
    JSP2 is perfectly working. I want to display the result of jsp2 with the result of jsp1.
    But I additionally want to supply a value from jsp1 to a variable in jsp2 before calling jsp2.
    The result of jsp2 depends on the value supplied.
    I couldn't figure out how to do this. A simple @include directive like
    <%@ include file="jsp2.jsp" %> doesn't seem to be suitable here.
    What options are available here? Please help.
    Thank you.

    Thank you friends for the suggestion. I have yet to try your suggestions.
    Before that I came across another problem. Would someone help please?
    Why the jsp fails when I include the same JSP page twice in another jsp page?
    Of the following two jsp files, the upper one is OK, but the lower one complains that it cannot compile (org.apache.jasper.JasperException).
    test1.jsp:
    <html><head><title></title></head>
    <body>
    <table>
    <tr><td><%@ include file="single.jsp" %></td></tr>
    </table>
    </body>
    </html>
    test2.jsp:
    <html><head><title></title></head>
    <body>
    <table>
    <tr>
    <td><%@ include file="single.jsp" %></td>
    <td><%@ include file="single.jsp" %></td>
    </tr>
    </table>
    </body>
    </html>
    I want to populate the cells of an HTML table with the results from the same jsp file, by supplying different values to a variable in the jsp file so that its results will be different for each cell. Am I being to foolish here?
    Thanks.

  • JSP newbie.  Strange classnotfoundexception

    I have recently started writing JSPs. I am an experienced Java programmer, but have not ventured into JSPs until just now.
    While writing some test JSPs, I have run into a big problem that I cannot seem to resolve.
    While attempting to run my JSP from IE, tomcat throws the following exception in the console window: java.lang.ClassNotFoundException: RTSite
    Also, unless I change the SITES_FN to "C:\\sites.dat" and place the sites.dat file in C:\, it tells me it cannot find the file. For example, if I change SITES_FN to simply "sites.dat" and place sites.dat in the C:\tomcat_5.5\webapps\ROOT directory alongside my outages.jsp file, it tells me it can't find it!
    How on earth do I fix this? What am I doing wrong?
    Here is my JSP:
    ===================================
    <%@page import="java.util.*,java.io.*,test.RTSite"%>
    <HTML>
    <BODY>
    <%!
         String SITES_FN = "C:\\sites.dat";
         String OUTAGES_FN = "outages.dat";
         String OUTAGES_TXT_FN = "outages.txt";
         boolean eof = false;
         RTSite site;
         //site = new RTSite("http://www.georgianavigator.com/perl/trips", "ATL", "Atlanta", "GA");
    %>
    <%
         site = new RTSite("http://www.georgianavigator.com/perl/trips", "ATL", "Atlanta", "GA");
         out.println(site.getName());     
         try
              FileInputStream in = new FileInputStream(SITES_FN);
              ObjectInputStream s = new ObjectInputStream(in);
              while (!eof)
                   try
                        site = (RTSite)s.readObject();
                        out.println("TEST" + site.getCode());
                   catch (EOFException ex)
                        eof = true;
              //s.close();
              //in.close();
         catch (Exception ex)
              out.println(ex.getMessage());
              System.out.println("=====");
              ex.printStackTrace();
    %>
    </BODY>
    </HTML>
    ===========================================
    Here is my directory structure:
    C:\tomcat_5.5
    +-----webapps
    -------+----ROOT
    -------------+----outages.jsp
    -------------+----sites.dat
    -------------+----WEB-INF
    -------------------+----classes
    --------------------------+----test
    --------------------------------+----RTSite.class                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Too many things to count.
    "ClassNotFoundException" isn't strange. Sounds like you didn't deploy your Web app properly.
    Is RTSite a class that you wrote? Where is the .class file located? (Hint: Should be in the WEB-INF/classes directory for your Web app, in its package directory structure.)
    Tomcat won't deal with any servlets or Beans that aren't in a package. If you aren't using packages, you'd better start.
    You should not be putting your app in /ROOT. Learn how to deploy Web apps to Tomcat properly. The Tomcat site has "Your First Web App" to show you how.
    You shouldn't have scriptlet code in a JSP like that. Better to learn JSTL.
    Your Web app should be self-contained. I'd expect to see everything I needed within the Web context. Tossing files like that site.dat just anywhere in the file system is a bad idea.
    The JSP is compiled to a servlet and run on the host server. I'll assume that you know this, and will place that sites.dat file accordingly.
    I'd always prefer a relational database to a static text file in the file system, but that's just me.
    That's enough for now.
    %

  • JSP newbie - exception handling question

    I have created a method in the declarations sections of my jsp. When a particular exception is found (caught inside my method), i want to be able to redirect the output to either another jsp page, or simply print a message on the page in which the exception occurred. I am having some trouble figuring this out. Any advice?

    There are many ways to do so.
    One way is to define error pages. The details about this is given in the article below
    http://java.sun.com/developer/EJTechTips/2003/tt0114.html
    Other way is to do something like this :
    if ( haveError ) {
    out.println( errors.toString());
    pageContext.include( "GetName.jsp" );
    } else
    pageContext.forward( "NextPage.jsp" );
    But, I have a suggestion, if possible, do not put method declaration in JSP pages. Its not a good practice. Put all the code in beans. JSP should only contain display stuff.
    Vaibhav

  • JSP Newbie need help

    Hi to all,
    I'm very new in using JSP, I was debugging an existing JSP codes when I encounter this problem. There's this two files these are as follows:
    resourcecenter_requestinfo.html / resourcecenter_requestinfo.jsp
    contact_requestinfo.html / contact_requestinfo.jsp
    From what I have observe there's a confilict on the _requestinfo subtitle part of the filename because when I try to execute this code the template for contact and resourcecenter overlapped. What I mean by overlapped is both output of those template appears after execution.
    I hope someone could help me on this or give me some tips.
    Thansk in advance....!
    Regards,
    John Drayton C. Fule
    Jr. Systems Engineer
    Imperium Techonology Inc.
    Philiipines

    ok thanks I double check it and try to rename it and it works. But another problem occurs. The looks of the output it not what I expected. some colors turned to red. Is there any way i can determine why it happen.

  • Jsp newbie - quantity*price=�total - help!

    Hi, im new to jsp and have made a few pages, and can display them using Tomcat, ive made a page counter and managed some validation of a form, but i cannot get this to work:
    i have a form where you can select a product, then type in the price and quantity, so when you press order, it should display a page showing you what you chose and the total cost, (tryin to also use dp2??) , but im gettin in a right mess! i have ziped the two pages here: http://www.severnvalebathrooms.co.uk/ordermarbrex.zip
    if someone could have a look, any help would be great!
    thanks

    what level feedback do you have on your server.
    look at variable names,
    you have:
    <%
        String quantity    = request.getParameter( "quantity"    ); 
        String price       = request.getParameter( "price"      );
                                                 // Create a convert for 2 decimal places
        java.text.DecimalFormat dp2 
                            = new java.text.DecimalFormat( "�#,##0.00" );
                                            // convert a string to type int                
        int    quantity = Integer.parseInt(   quantity ); 
                                            // convert a string to type double         
        double price    = Double.parseDouble( price    );
        String strips      = request.getParameter( "strips"      );     
        String whofor      = request.getParameter( "whofor"      );
        String bluemosaic  = request.getParameter( "bluemosaic"  );         
        String greenmosaic = request.getParameter( "greenmosaic" );         
        String beigemarble = request.getParameter( "beigemarble" );         
        String delivery    = request.getParameter( "delivery"    );
        if( bluemosaic  == null ) bluemosaic  = "";
        if( greenmosaic   == null ) greenmosaic   = "";
        if( beigemarble == null ) beigemarble = "";     
    %> you should have like;
    <% 
        String quantity    = request.getParameter( "quantity"    ); 
        String price       = request.getParameter( "price"      );
                                                 // Create a convert for 2 decimal places
        java.text.DecimalFormat dp2 
                            = new java.text.DecimalFormat( "�#,##0.00" );
                                            // convert a string to type int                
        int    quantities = Integer.parseInt(   quantity ); 
                                            // convert a string to type double         
        double dPrice    = Double.parseDouble( price    );
        String strips      = request.getParameter( "strips"      );     
        String whofor      = request.getParameter( "whofor"      );
        String bluemosaic  = request.getParameter( "bluemosaic"  );         
        String greenmosaic = request.getParameter( "greenmosaic" );         
        String beigemarble = request.getParameter( "beigemarble" );         
        String delivery    = request.getParameter( "delivery"    );
        if( bluemosaic  == null ) bluemosaic  = "";
        if( greenmosaic   == null ) greenmosaic   = "";
        if( beigemarble == null ) beigemarble = "";     
    %> then change output vars to reflect this at bottom of page.
    also i would do some checking of input vars
    try calling this;
    process_marbrex.jsp?quantity=xyzkind regards,
    g00fy

  • JSP newbie question

    Hello,
    I am trying to interface a service using JSP and servlets. I am getting a couple of difficulties, i would appreciate any help.
    I am using Tomcat 4.1 and Java 1.4.2. I initially have a jsp that has a form, the action is my servlet and the method is post. Among the things i submit in form I have an
    <input type=file name="thename">
    which i later try to retrieve in the servlet as:
    Object o=request.getAttribute("thename")
    This doesnt seem to work (always null) and don't know what to use instead.
    At some point i want to show status information back to the user at a certain refresh rate. How can this be done. If i output from the servlet html code with <meta http-equiv="refresh" content="10"> i get an error at the first refresh attempt.
    Thank you for any help,
    Gabri

    Yes sorry, it is parameter.

  • JSP newbie: Servlet and then?

    hi
    just starting to do a jsp webapp - could manage to have a registration form with a preview button
    by clicking on the submit button the action refers to my servlet class which shows me the entered values
    but now i want to add a save button - but where do i have to do this? please help me at the moment i do not see any solution :(

    This is the perfect example of where you should be using a JSP instead of a servlet.
    It is much harder to read in the above format, where as if you look at it like this:
    </TABLE>
    <FORM ACTION="><a href="imac2\private\test.jsp>">
    <BIG><CENTER>
    <INPUT TYPE="SUBMIT"
               VALUE="Save">
    </CENTER></BIG></FORM>It becomes a lot easier to read, and it is quite clear that the form tag action attribute is a little wonky. you do not put an <a href> tag in the middle of a form tag :-)
    I think your form tag should instead be this:
    <form action="[path/to/requested/resource]">
    or in your terms:
    "<FORM ACTION=\"" + "imac2\\private\\test.jsp" + "\">\n" +
    In most cases the action of a form points to a servlet to invoke.
    You can make it a JSP if you wish, but then the JSP will be handling the form data, and (in the strict model2 architecture) JSPs should only be used for display.
    The basic story:
    If you are using out.println() to output a whole lot of HTML, you should be using a JSP
    If a JSP has a whole bunch of scriptlet code in it, you should be using custom tags or a servlet.
    The standard approach (as I showed above) is to submit to a servlet, have the servlet run java code (to save/load/do whatever) and then forward to a JSP to render the response (using the RequestDispatcher)
    Hope that clears things up a little,
    evnafets

  • JSP newbie: local Sun Java System Application Server installation

    I am new to JSP and I am preparing to get the software I need. JDK 6 and Netbeans 6 are installed. Now I need an application server. Since the Sun tutorials use the "Sun Java System Application Server" I have choosen this one (version 9.1). As far as I know I could also use, e.g., Tomcat or Glassfish (correct?).
    I just would like to install the application server for learning JSP.
    Could I safely install the Sun Java System Application Server on my PC so that the application server only listens to local calls? Does it use a lot of system ressources while idle?
    Thanks!

    I`ve posted a shorter version of the question in the hopes of getting a timely answer. Thanks

  • Javascript !--ipt tag in jsp    newbie question

    My jsp engine and/or the server is mangling javascript's <script> tag. Any ideas?
    I'm using Tomcat 4.0.3 and JDK 1.3.1_01. Will appreciate any help.
    Regards,
    Tom
    1.
    Original jsp:
    <SCRIPT language="javascript">
    // javascript code
    </SCRIPT>
    As seen by browser:
    <!--IPT language="javascript">
    // javascript code
    </SCRI-->
    The intermediate java source code produced by the jsp-compiler looks fine, e.g.:
    out.write("\r\n\r\n<html>\r\n<head>\r\n\r\n<SCRIPT language=\"javascript\">\r\n\r\nfunction test()\r\n{\r\n\talert(\"testing\");\r\n}\r\n\r\n</SCRIPT>\r\n</head> etc.
    2.
    Tried several other ways of generating the script tag. Result so far has been the same as above.
    a)
    <%= "<script ...>"%>
    b)
    <scr<%= "i"%>pt>

    Putting it inside the JSP comments <%-- <script> ... </script> --%>
    isn't working for me. Results in the entire javascript code not being outputted.
    By the way, if you notice the subject line, that's a similar phenomenon. I'd actually typed in "Javascript <script> tag ..." in the original subject line...
    Any other ideas?
    Tom

  • Simple question from jsp newbie

    Hi friends,
    I am learning jsp now. Reading documents and implementing simple applications. But i want to ask a question that is opposite to my logic.
    Now, i am a textfield control on jsp as textField1. I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.
    Thanks.

    technologyMan wrote:
    I am learning jsp now. You´re actually at the JSF forum here.
    Now, i am a textfield control on jsp as textField1. You are? Really?
    I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.Uh, just write code accordingly? You can use h:commandButton/h:commandLink for that.
    Anyway, if you want to start with JSF, I can recommend you the following sources:
    Java EE tutorial part II, JSF starts at chapter 10: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Good kickoff tutorial: [http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html]
    The JSF taglib documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/]
    The JSF API documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/overview-summary.html]

Maybe you are looking for