Head  first jsp

hello
i need this book as a soft copy :
head first jsp & servlet.
thanx

To avoid having to use the classpath over and over add it to your system environment variables:
Right click 'My Computer' > Properties > Advanced > Environment Variables
Under 'System Variables' if you don't already have have a 'CLASSPATH', create one. If you do, append the path to your servlet-api.jar ( e.g. c:\Tomcat\common\lib\servlet-api.jar ). Remember, different entries into the classpath must be separated by semi-colons (;).
Save and open a fresh console window ( the changes don't reflect in consoles that were already open ).
Of course, you should still learn how to work with the classpath variable: http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/classpath.html
This is what your command should be:
javac -classpath c:\Tomcat\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java

Similar Messages

  • Head First book & Tomcat setup

    I am currently reading Head First Servlets & JSP. In the first chapter it gives you a sample servlet to run(Ch1Servlet.java). It tells you to setup a directory OUTSIDE of /tomcat.
    /Project1
    /Project1/src
    /Project1/classes
    /Project1/etc
    On my computer it is setup as C:/Java/Project1
    Then it tells you to compile it from the command line like this:
    javac -classpath /your path/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java
    Here is what I used
    javac -classpath /Program Files/Apache Software Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java
    This causes an error
    javac usage invalid: Files/Apache
    I am guessing this is because there are spaces in the classpath name. I copied the servlet-api.jar to the C:/Java folder and it compiled successfully. Without having to copy files to other folders how can I get around this error?
    Once you get it compiled it tells you to add the class files to the WEB-INF/classes directory and add the web.xml to the WEB-INF/etc directory. The book didn't explain where this directory is. I only imagined it being on its own in the Tomcat5.5 directory but it wasn't there. I looked under webapps and there is not a WEB-INF directory. What is the book trying to tell me?
    It also tells me once Tomcat is started to type in http://localhost:8080/ch1/Serv1. Under the web.xml file the mapping url is set to /Serv1 but the other description in servlet mapping is Chapter 1 Servlet. I don't see where the ch1 directory is. Can anyone help me with this?
    My system OS: Windows XP
    It also didn't explain why you would setup a directory outside of tomcat and then have to deploy your compiled classes back into tomcat. I am fairly new to Java and brand new to JSP. This part of the book seems to assume I know all this. Can anyone put me in the right direction?

    I am currently reading Head First Servlets & JSP. In
    the first chapter it gives you a sample servlet to
    run(Ch1Servlet.java). It tells you to setup a
    directory OUTSIDE of /tomcat.
    /Project1
    /Project1/src
    /Project1/classes
    /Project1/etc
    On my computer it is setup as C:/Java/Project1
    Then it tells you to compile it from the command line
    like this:
    javac -classpath /your
    path/tomcat/common/lib/servlet-api.jar -d classes
    src/Ch1Servlet.java
    Here is what I used
    javac -classpath /Program Files/Apache Software
    Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d
    classes src/Ch1Servlet.java
    This causes an error
    javac usage invalid: Files/Apache
    I am guessing this is because there are spaces in the
    classpath name. I copied the servlet-api.jar to the
    C:/Java folder and it compiled successfully. Without
    having to copy files to other folders how can I get
    around this error?
    Add double quotes around your class path (e.g. javac -classpath "c: /Program Files/Apache Software Foundation/Tomcat 5.5/common/lib/servlet-api.jar ")
    Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d
    classes src/Ch1Servlet.java
    Once you get it compiled it tells you to add the
    class files to the WEB-INF/classes directory and add
    the web.xml to the WEB-INF/etc directory. The book
    didn't explain where this directory is. I only
    imagined it being on its own in the Tomcat5.5
    directory but it wasn't there. I looked under webapps
    and there is not a WEB-INF directory. What is the
    book trying to tell me?
    You want to create a directory called ch1 under tomcat's webapps directory.
    Under the ch1 directory create a WEB-INF directory. And under WEB-INF create a
    classes directory.
    It also tells me once Tomcat is started to type in
    http://localhost:8080/ch1/Serv1. Under the web.xml
    file the mapping url is set to /Serv1 but the other
    description in servlet mapping is Chapter 1 Servlet.
    I don't see where the ch1 directory is. Can anyone
    help me with this?
    The url-pattern in the web.xml is what is used to access your servlet.
    Chapter1 Servlet is just a way to map from the servlet-class to the url-pattern.
    If you read further in the book all this will be explained.
    My system OS: Windows XP
    It also didn't explain why you would setup a
    directory outside of tomcat and then have to deploy
    your compiled classes back into tomcat. I am fairly
    new to Java and brand new to JSP. This part of the
    book seems to assume I know all this. Can anyone put
    me in the right direction?You want your source to be outside of tomcat. Once you have compiled everything,
    you then deploy to your container. Hope this helps

  • Head First Java

    I'm looking for a good book to learn Java with. Head First Java seems to be fairly good by the Amazon reviews, but I was wondering if anyone who's read it could answer a few questions.
    1. Would it be any good for someone good at other programming language
    2. How advanced does it get?
    3. Does it teach fairly good application design?

    1. The book is intended for people who have a basic understanding of programming, so knowledge of other programming languages will be an advantage.
    2. It covers quite a few basics of programming in Java, including some GUI development, Sockets, and Threads.
    3. It steps you through building some applications that incorporate good design techniques. It's not intended as a discourse on application design, but it provides some good fundamentals.
    In my opinion, it's a fantastic book and a very entertaining read.

  • Upon refreshing the page, why always first.jsp  is displayed ?

    Hi all,
    In case of multipage portlet (jpdk example), why always the first.jsp is displayed upon clicking the refresh button of the page containing the multipage portlet even when we are viewing the second.jsp. Can we avoid this?
    Best regards,
    Omer

    Hi,
    As it's visible here Struts 1 doesn't have this component. Although this is 1.3.8 struts version but I doubt if in 1.3.10 TabbedPanel is already implemented. So nothing unusual that it's not working.
    To use this component (class) You've to download the latest Struts version (it would be Struts 2 of course) and migrate Your project from Struts 1 to Struts 2. I don't know Struts 1 very well but I read several articles about migration to the latest version and this migration was worth it. Is see this article as very helpful in this case.
    And 'struts-tags' is not a class. This a tag library directive that names the library which contains the tags. This uri is declared in a tld file (tag library descriptor) which is special descriptor for the whole library.

  • First JSP assignment

    Pls, I designed a form subscription.jsp to take data.
    When submit of the form is clicked, the data of the form should be verified by the processSub.jsp to make sure that all the data are entered.
    If some data are not entered, an error indicating those ones that are not entered will be displayed . it should also have an hyper link (here) to go back to the subscription form. and the already entered data should be retained with session object. However, if everything is entered correctly, the data entered into the subscription should be redisplayed. I did all these, but it did not work. Pls I need assistance. I commented processSub.jsp to guild any person that would want to help
    <-- The file name is subscription.jsp --->
    <html>
    <head>
    <title>Subscription</title>
    </head>
    <body>
    <form method=post action="processSub.jsp">
    <table border=1 >
    <caption align="center"><b> XYZ Publication</b></caption>
    <tr><td align=right>Subscription Length</td><td><input type=radio name=radone value=1>One Year<input type=radio name=radtwo value=2>Two Year<input type=radio name=radthree value=3>Three Year</td></tr>
    <tr><td align=right>First Name:</td><td><input type=text name="txtfirstName"></td></tr>
    <tr><td align=right>Last Name:</td><td><input type=text name="txtlastName"></td></tr>
    <tr><td align=right>Address:</td><td><input type=text name="txtaddress"></td></tr>
    <tr><td align=right>City:</td><td><input type=text name="txtcity"></td></tr>
    <tr><td align=right>State:</td><td><input type=text name="txtState" SIZE=5></td></tr>
    <tr><td align=right>Zip Code:</td><td><input type=text name="txtZipCode"></td></tr>
    <tr><td align=right>Phone:</td><td><input type=text name=txtPhone></td></tr>
    <tr><td align=right>Email Address:</td><td><input type=text name="txtemail"></td></tr>
    <tr><td align=right>Name on Card:</td><td><input type=text name="txtCardName"></td></tr>
    <tr><td align=right>Card Type:</td><td><select name="selcard"><option value="v">Visa<option value="M">Master<option value="C" >Credit<option value="N" selected>Select a card type</select></td></tr>
    <tr><td align=right>Card Number:</td><td><input type=text name="txtcardNumber"></td></tr>
    <tr><td align=right>Expiration Date:</td><td><input type=text name="txtExpiration"></td></tr>
    <tr><td colspan=2 align="center"><input type=submit value="Subscribe" ></td></tr>
    </table>
    </form>
    </body>
    </html>
    <-- The file name is processSub.jsp -->
    <%@ page language="java" contentType="text/html" %>
    <%! String error; %>
    <html>
    <body>
    <%
          // Retrieve all of the data that the user entered by using the request object
         String chrLenght = request.getParameter("intlenght");
         String chrFirstName = request.getParameter("txtfirstName");
         String chrLastName = request.getParameter("txtlastName");
         String chrAddress = request.getParameter("txtaddress");
         String chrCity = request.getParameter("txtcity");
         String chrState = request.getParameter("txtState");
         String chrZipCode = request.getParameter("txtZipCode");
         String chrPhone = request.getParameter("txtPhone");
         String chrEmail = request.getParameter("txtemail");
         String chrCardName = request.getParameter("txtCardName");
         String chrCardType = request.getParameter("selcard");
         String chrCardNumber = request.getParameter("txtcardNumber");
         String chrExpDate = request.getParameter("txtExpiration");
    // Check to see if the first name was entered
         if(chrFirstName == null)
              error = " You must enter in first name.<br>";
    // Check to see if the last name was entered
         if(chrLastName == null)
              error = error + " You must enter in last name.<br>" ;
    // Check to see if the address was entered
         if(chrAddress == null)
              error = error + " You must enter in address.<br>";
    // Check to see if the city was entered
         if(chrCity == null)
              error = error + " You must enter in city.<br>" ;
    // Check to see if the state was entered
         if(chrState == null)
              error = error + " You must enter in state.<br>" ;
    // Check to see if the zip code was entered
         if(chrZipCode == null)
              error = error + " You must enter in zip code.<br>" ;
    // Check to see if the phone was entered
         if(chrPhone == null)
              error = error + " You must enter in phone.<br>";
    // Check to see if the Email was entered
         if(chrEmail == null)
              error = error + " You must enter in email.<br>";
    // Check to see if the card name was entered
         if(chrCardName == null)
              error = error + " You must enter in card name.<br>";
    // Check to see if the card type was entered
         if(chrCardType == null)
              error = error + " You must enter in card type.<br>";
    // Check to see if the card number was entered
         if(chrCardNumber == null)
              error = error + " You must enter in card number.<br>";
    // .length()
    // Check to see if the expiration date was entered
         if(chrExpDate == null)
              error = error + " You must enter in expiring date.<br>";
    // Now check if there are any errors.
         if(error != null)
         { %>
              There is an error in your subscription<br>
              <font color="red"><%=error%></font>
    <!-- link back to the subscription page -->
              <br>
              Click <a href="subscription.jsp">here</a> to update.
              <%
                   session.setAttribute("sublenght",chrLenght);
                   session.setAttribute("firstname",chrFirstName);
                   session.setAttribute("lastname",chrLastName);
                   session.setAttribute("address",chrAddress);
                   session.setAttribute("city",chrCity);
                   session.setAttribute("state",chrState);
                   session.setAttribute("zipcode",chrZipCode);
                   session.setAttribute("phone",chrPhone);
                   session.setAttribute("email",chrEmail);
                   session.setAttribute("cardname",chrCardName);
                   session.setAttribute("cardtype",chrCardType);
                   session.setAttribute("cardnumber",chrCardNumber);
                   session.setAttribute("expdate",chrExpDate);
              %>
         <% }
         else
         { %>     
    <!-- Thank the customer for the order -->          
              <b> Thanks for your order! it will be processed imediately</b>
    <!-- Redisplay the data entered into the subscription -->
              <br><br>
              <table border=1 >
              <caption align="center"><b> XYZ Publication</b></caption>
              <tr><td align=right>Subscription Length</td><td><%=chrLenght%></td></tr>
              <tr><td align=right>First Name:</td><td><%=chrFirstName %></td></tr>
              <tr><td align=right>Last Name:</td><td><%=chrLastName %></td></tr>
              <tr><td align=right>Address:</td><td><%=chrAddress%></td></tr>
              <tr><td align=right>City:</td><td><%=chrCity%></td></tr>
              <tr><td align=right>State:</td><td><%=chrState%></td></tr>
              <tr><td align=right>Zip Code:</td><td><%=chrZipCode%></td></tr>
              <tr><td align=right>Phone:</td><td><%=chrPhone%></td></tr>
              <tr><td align=right>Email Address:</td><td><%=chrEmail%></td></tr>
              <tr><td align=right>Name on Card:</td><td><%=chrCardName%></td></tr>
              <tr><td align=right>Card Type:</td><td><%=chrCardType%></td></tr>
              <tr><td align=right>Card Number:</td><td><%=chrCardNumber%></td></tr>
              <tr><td align=right>Expiration Date:</td><td><%=chrExpDate%></td></tr>
              </table>
         <% } %>
    </body>
    </html>
              

    The program is supposed to show error messages indicating the fields that are left blank when submit in subscription.jsp is clicked. e.g
    errors:
    You did not enter your first name.
    You did not enter your last name. etc
    But it doesn't show it. And again, session.setArribute doesn't work .look at the code for it
    if(error != null)
         { %>
              There is an error in your subscription<br>
              <font color="red"><%=error%></font>
    <!-- link back to the subscription page -->
              <br>
              Click <a href="subscription.jsp">here</a> to update.
              <%
                   session.setAttribute("sublenght",chrLenght);
                   session.setAttribute("firstname",chrFirstName);
                   session.setAttribute("lastname",chrLastName);
                   session.setAttribute("address",chrAddress);
                   session.setAttribute("city",chrCity);
                   session.setAttribute("state",chrState);
                   session.setAttribute("zipcode",chrZipCode);
                   session.setAttribute("phone",chrPhone);
                   session.setAttribute("email",chrEmail);
                   session.setAttribute("cardname",chrCardName);
                   session.setAttribute("cardtype",chrCardType);
                   session.setAttribute("cardnumber",chrCardNumber);
                   session.setAttribute("expdate",chrExpDate);
              %>
         <% }

  • How can I pass a variable  value from first jsp page to thired jsp page

    In my program ,threr are three jsp pages . I want the first pages's variable value in to thired page .How can I acess.
    I used the request.getparameter() ,but when I print the value , null value is getting .

    request parameters only last for one request.
    To save them longer than that you need to save them somewhere.
    Couple of alternatives
    1 - store them to session
    session.setAttribute("username", request.getParameter("username");
    2 - create a hidden field on page 2 and store the value from page 1 there. When you submit page2, you can get it on page3 with request.getParameter again.
    <input type="hidden" name="username" value="<%= request.getParameter("username") %>">

  • I want to use the custom request header in JSP How can I use that

    Hi Guys,
    I have following scenerio...
    1: There is one third party tool which is calling my.jsp page from the specified directory.
    2: Before calling the JSP that third party tool is adding some data like <user name> and <password > in the header of that JSP.
    Problem: I am not getting thos custom added header in side the JSP.
    Header information is given below:
    http://localhost:8100/wvsat/brand/ncr/auto.jsp
    GET /<APPLICATION_NAME>/ <JSP_PAGE_NAME>.jsp HTTP/1.1
    Host: localhost:8100
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Cookie: AreCookiesEnabled=195; JSESSIONID=2a30e33e48384dd13222
    MyUsername: demo*
    MyPassword : demo*
    HTTP/1.x 200 OK
    Date: Wed, 24 Sep 2008 19:42:22 GMT
    Content-Type: text/html; charset=UTF-8;application/x-www-form-urlencoded
    Connection: close
    Server: JRun Web Server
    Now within the JSp page i want the value of MyUserName and MyPassword
    For gettting these value i am using the request.getHeader(MyUserName);But it is returning null.
    Note:+*
    1: I want to forward this value to another servlet which is based on Struts framework_.
    2: For adding the value in the header i am using Http Live header Addons of FireFox_
    Could anyone help me in the same!!!
    Thanks in Advance

    Sorry, perhaps I was not explicit enough.
    Your code snippet: request.getHeader(MyUserName);
    It was missing quotes to make it a String value.
    If that is what you have, then it is using the VARIABLE MyUserName, and not the actual value "MyUserName"

  • Dynamic Header in JSP

    hi
    i need to have single Login.jsp whose Header will change.
    Looks of header will depend upong Id value present in HTTP HEADER.
    Lets say user A with id value 1 hit Login.jsp URL. it will show header with company abc.com LOGO and other info
    now user A with id value 2 hit Login.jsp URL it will show header with company xyz.com LOGO and other info.
    Thanks,
    Harpreet

    Have context for every user. User context may contain user id, group (affiliate, company etc.) id, preferences etc.
    For every group id maintain image folder name, css folder name etc. in database or file. When the JSP page is invoked, depending on user's context use different paths for images, css etc.
    Thanks,
    Mrityunjoy

  • Html link not visible as table header in jsp

    Hi,
    I am not sure if this question belongs to JSP forum, since it's happening in JSP page I am posting it here.
    I am seeing this strange problem, in my JSP page all the link are looking fine except some links in Table header. Here is the code snippet:
    <th align="left" width="30%"><html:link action="/myAction.do?sortBy=org&all=${param.all}">Organization Name</html:link></th>
    ENV is struts, jstl, html.
    Now the problem is the text Organization Name is not visible, although it's there and I can click it. If I click and drag mouse over it I can see it.
    Also if I put this link anywhere else e.g. <TD> I can see it.
    I am not sure why it's happening.
    Please help me.
    Abhishek

    Sounds like a style issue - is it the same colour as the background for some reason?
    What styles have you got applied to your <th> columns? The text in them?
    Are you using css?

  • DOCTYPE header in JSP

    Is the web address in the DOCTYPE header really necessary? Should the DOCTYPE header be omitted from .jsp pages?

    To add to J-Fine's reply, in general, there is a browser and a server. The browser makes a request, the server gives a response, the browser shows the response. It doesn't matter that the response contains HTML from a plain HTML file, an image file, a video file, or an error message (typically as HTML), it always works the same.
    This has nothing to do with JSP, CGI, ASP, PHP or anything else. All those things (JSP, CGI, etc.) do is provide ways to generate and/or send the response content. A CGI can create HTML content, image content, video content or error messages.
    A little history (highly generalized):
    In the begining, the gods created HTML, and it was good. Then one day, man said to the gods "These HTML files are nice, but what if I want to display how many times the page has been seen?" And the gods responded by creating CGI and SSI and said "Hey, that little language called Perl would work nicely here." , and it was good. Then one day, Bill Gates said "Hey, I can do better then SSI and Perl CGIs by letting you write in VBScript right in with the HTML.", and it was okay if you could write VBScript and figure out how to write COM objects. Then one day Sun said, "Hey, VBScript is crap, why not use Java as the language, which will allow connecting lots of other Java code, which is easier then writing COM objects and can run on Unix.", and so it was much better. Then one day some people said, "Hey, lets do the same thing, but make it use a language that looks similar to Perl, since we all know Perl CGIs already.", and PHP was created and it was also good.
    (okay, I left out ColdFusion, and maybe PHP came before JSP, which itself came after server-side Java)

  • First JSP/Tomcat 5.5 test

    Hi,
    I'm new in Java and i'm trying to create a web application in JSP.
    Basically, it should connect to a MS access database for the first steps, after it should use a MySQL DB.
    In this purpose i would like to build this web application as flexible as it is, because i don't want to recompile or rebuild code from migration Access to MySQL.
    1. where can i find a good tutorial about tomcat 5.5 setup ? I have a book for now, but it's very long way to first test...i just cover 10 % in 2 days. :(
    2. where can i find a very good tutorial about connect MS access DB from JSP ?
    3. how to it as flexible as i want ?
    thx,
    Maileen

    1. where can i find a good tutorial about tomcat 5.5
    setup ? I have a book for now, but it's very long way
    to first test...i just cover 10 % in 2 days. :(http://www.coreservlets.com/Apache-Tomcat-Tutorial/
    http://jakarta.apache.org/tomcat/tomcat-5.5-doc/index.html
    2. where can i find a very good tutorial about
    connect MS access DB from JSP ?you mean JDBC http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/index.html
    3. how to it as flexible as i want ?you can save the connection string and the jdbc driver class name and the username and password to a file and then you application should read this data from that file. when you need to move form access to mysql just change the data in the file

  • Setting response header fron JSP

    Hi
    I would like to know how I can set "If-Modified-Since" header, so that when client refreshes the page again the server should send 304 (Not Modified) status to the client.
    I was able to do this in servlets as follows,
    {code}
    class Servlt extends HttpServlet
        private long modifiedTime ;
        init()
            modifiedTime=System.timeMilliSeconds /1000*1000;
        //service method automatically calls getLastModified() for the conditional GET
        long getLastModified()
             return modifiedTime;
    {code}
    How I can achieve the same in JSP ?
    Is this work for POST method?
    Is refreshing the browser submits page with GET or POST ?
    Please help me understanding these and the solution for the above using JSP.
    Thanks in advance.{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Try to set "Last-Modified" response header via setDateHeader method.

  • Date Header from JSP

    Has anyone managed to set the date header in a JSP file?
    I'm generating an XML file - response.setContentType("text/xml");
    and I want IE7 to be able to cache the file but the Date Header seems to get filled in on my behalf at the end of the page even though I have :
    response.addHeader("Date", "Tue, 12 Feb 2008 10:00:00 GMT");
    I've tried setHeader and the addDateHeader/setDateHeader alternatives.
    I've set the cache-control but I can see using Fiddler that the Date Header of the reply is just set to the current date/time which forces IE7 to do a full load.
    Thanks.

    Have you also tried: response.setHeader("Cache-Control", "post-check=####"); with #### = some number?
    Microsoft calls this "lazy update" see http://support.microsoft.com/kb/843526/en-us:
    A Post-check directive is a cache-control directive that is included with the HTTP Expires header. Web sites use the HTTP Expires header to control how Internet Explorer caches content on the Web site. Post-check defines a time interval (in seconds) that defines after which an object must be checked for "freshness". This check allows Internet Explorer to display the content from its cache or in the Temporary Internet Files folder, and then update the cached copy of the content in the background. This update is also known as a lazy update.
    But they don't really document this well. Do you get the same result using other browsers?
    Finally I'd recommend that you ask this question at the http://forum.java.sun.com/index.jspa forums. The forum you have posted to here is specific to the Sun Java Studio Enterprise IDE developer tool, and since your question is not tool specific, you will receive very few responses to your post here.
    Regards,
    -Brad Mayer

  • Please Help with my first jsp

    Hi, this may seem basic to you but i've frying my head with simple jsp. Any books i looked at only show code segments!
    All i want to do is create an html entry page with form fields for username, password, email address, send the information to a jsp page that validates the form entries and then stores the info in database, and be able to display the info stored in the db also.
    Any help or pointers would be appreciated, or links to good tutorials!
    Thanks in advance.....

    with this i am sending my own code :
    its a html page :
    <Script LANGUAGE="JavaScript" ></Script>
    <%@ page import="java.util.*" %>
    <%@ page import="java.lang.*" %>
    <html>
    <head>
    <title>Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Microsoft Theme" content="expeditn 011">
    </head>
    <body background="exptextb.jpg" bgcolor="#FFFFFF" text="#000000" link="#993300" vlink="#666600" alink="#CC3300">
    <!--mstheme--><font face="Book Antiqua, Times New Roman, Times">
    <form name="frmlogin" method="post">
    <p> 
    </p>
    <p> 
    </p>
    <p> 
    </p>
    <p> 
    </p>
    <p>                                                       
    User Name : 
    <input type="text" name="txtname">
    <br>
    <br>
    Password   : 
    <input type="password" name="txtpassword">
    </p>
    <p>                                                                    
    <input type="submit" name="submit" value="Submit" onclick="javascript: return loadmy('sub')">
    </p>
    </form>
    <script>
    var i=0;
    function loadmy(val)
              if(val=="new")
                   document.frmlogin.action='form.jsp';          
              }else
                   if(onCheck())
                        document.frmlogin.action='login.jsp';
                   }else
                        return false;
    function onCheck()
         if(document.frmlogin.txtname.value=="")
              alert("Please enter user name ..");
              document.frmlogin.txtname.select();
              document.frmlogin.txtname.focus();
              return false;
         if( document.frmlogin.txtpassword.value=="")
              alert("Please enter password ..");
              document.frmlogin.txtpassword.select();
              document.frmlogin.txtpassword.focus();
              return false;
         return true;
    </script>
    <p> </p><!--mstheme--></font></body>
    </html>
    IN this page i am taking user name and password. ok?
    now another JSP file with database connection is here: I think you have enough idea for database connection. So i'll ommit that.
    <html>
    <head>
    <title>Login Result Page</title>
    <meta name="Microsoft Theme" content="expeditn 011">
    </head>
    <%@ page import="java.lang.*,java.sql.*"%>
    <%@ page import ="Database.*" %>
    <body background="exptextb.jpg" bgcolor="#FFFFFF" text="#000000" link="#993300" vlink="#666600" alink="#CC3300">
    <!--mstheme--><font face="Book Antiqua, Times New Roman, Times">
    <%
         String uname = request.getParameter("txtname");
    String password = request.getParameter("txtpassword");
         String pquery="Select * from login where uname='"+uname+"'";
         String query="Select * from login where uname='"+uname+"'and password='"+password+"'";
         ClsDataBase cdb = new ClsDataBase();
         Connection con = cdb.getConnection();
         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery(pquery);
         if(rs!=null)
              if(rs.next())
                   ResultSet r=stmt.executeQuery(query);
                   if(r!=null)
                        if(r.next())
                        session.setAttribute("uname",uname);
                        session.setAttribute("Lflag","true");
    %>
    <p><font size=4 color="green">Wel Come <%= uname %>!!!</font></p>
    <p>
    <form action="listofuser.jsp" method="post" name="f1">
    </form>
    <%                    }
                        else
    %>
    <p> <font size=4 color="red">Wrong Password.</font> </p>
    <p><font size="4" color="green">Go back to login screen</font></p>
    <%
              else
    %>
         <font size=4 color="red">Invalid user....</font>
         <p><font size="4" color="green">Go back to login screen</font></p>     
    <%
         stmt.close();
         cdb.close();
    // conn.close();
    %>
    <!--mstheme--></font>
    </body>
    </html>
    hope this will help you. bye....

  • Errors when compiling my first jsp page in JDev. Help please....

    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/customizable" prefix="cust"%>
    HI everyone in my page.jsp at the line shown above is mark as error and the and the code assists help propose me to:-
    1) install jsp tag library
    2) Remove unused tag directive
    If i do the second i get two more errors. which are
    1) OrionHttpJspPage not found in class _untitled1
    2) method getPageContext(_untitled1, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, null, boolean, int, boolean) not found in class javax.servlet.jsp.JspFactory
    Can anyone help me plz how to do the install jsp tag library and what are the library to install and how to do it thanks a lot
    Am really new to ADF and JSF.
    Thanks a lot
    Lutchumaya

    Add the Customizable Components Core library to classpath.
    To deploy to a web application WAR file add the Customizable Components Core library to WEB-INF/lib.

Maybe you are looking for