How to Compali this SERVLET????

This is how my servlet class looks like. Any body can give me some hints on how to compile this servlet class.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Form extends HttpServlet {
     public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
     response.setContentType("text/html");
     PrintWriter out = response.getWriter();
     String title = "Investment Form";
     out.println(ServletUtilities.headWithTitle(title) +
          "<BODY BGCOLOR=\"#FDF5E6\">\n" +
          "<H1 ALIGN=CENTER>" + title + "</H1>\n" +
          "<UL>\n" +
          " <LI><B>MEMBER</B>: "
          + request.getParameter("MEMBER") + "\n" +
          " <LI><B>Name</B>: "
          + request.getParameter("Name") + "\n" +
          " <LI><B>SSN</B>: "
          + request.getParameter("SSN ") + "-"
          + request.getParameter("SSNn ") + "-"
          + request.getParameter("mem_ssn") +
          " <LI><B>Account</B>: "
          + request.getParameter("Account") + "\n" +
          " <LI><B>Address1</B>: "
          + request.getParameter("Address1") + "\n" +
          " <LI><B>Address2</B>: "
          + request.getParameter("Address2") + "\n" +
          " <LI><B>City</B>: "
          + request.getParameter("City") + "\n" +
          " <LI><B>State</B>: "
          + request.getParameter("State") + "\n" +
          " <LI><B>ZIP</B>: "
          + request.getParameter("ZIP") + "\n" +
          " <LI><B>WorkPhone</B>: "
          + request.getParameter("WorkPhone") + "\n" +
          " <LI><B>HomePhone</B>: "
          + request.getParameter("HomePhone") + "\n" +
          " <LI><B>Email</B>: "
          + request.getParameter("Email") + "\n" +
          " <LI><B>Amount</B>: "
          + request.getParameter("Amount") + "\n" +
          "</UL>\n" +
          "</BODY></HTML>");
          

You can compile your servlet as you do for ordinary classes.
like
javac servletfile.java
but do check before you compile that, your servlet.jar or j2ee.jar is there in class path or not.
after compilation put your servlet class in the classes dierectory of your Webserver.

Similar Messages

  • How to convert this Servlet into JSP

    I am trying to convert this Servlet into JSP page.
    How do I go about doing this?
    Thanks.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    /** Shows all items currently in ShoppingCart. Clients
    * have their own session that keeps track of which
    * ShoppingCart is theirs. If this is their first visit
    * to the order page, a new shopping cart is created.
    * Usually, people come to this page by way of a page
    * showing catalog entries, so this page adds an additional
    * item to the shopping cart. But users can also
    * bookmark this page, access it from their history list,
    * or be sent back to it by clicking on the "Update Order"
    * button after changing the number of items ordered.
    * <P>
    * Taken from Core Servlets and JavaServer Pages 2nd Edition
    * from Prentice Hall and Sun Microsystems Press,
    * http://www.coreservlets.com/.
    * &copy; 2003 Marty Hall; may be freely used or adapted.
    public class OrderPage extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    HttpSession session = request.getSession();
    ShoppingCart cart;
    synchronized(session) {
    cart = (ShoppingCart)session.getAttribute("shoppingCart");
    // New visitors get a fresh shopping cart.
    // Previous visitors keep using their existing cart.
    if (cart == null) {
    cart = new ShoppingCart();
    session.setAttribute("shoppingCart", cart);
    String itemID = request.getParameter("itemID");
    if (itemID != null) {
    String numItemsString =
    request.getParameter("numItems");
    if (numItemsString == null) {
    // If request specified an ID but no number,
    // then customers came here via an "Add Item to Cart"
    // button on a catalog page.
    cart.addItem(itemID);
    } else {
    // If request specified an ID and number, then
    // customers came here via an "Update Order" button
    // after changing the number of items in order.
    // Note that specifying a number of 0 results
    // in item being deleted from cart.
    int numItems;
    try {
    numItems = Integer.parseInt(numItemsString);
    } catch(NumberFormatException nfe) {
    numItems = 1;
    cart.setNumOrdered(itemID, numItems);
    // Whether or not the customer changed the order, show
    // order status.
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Status of Your Order";
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>");
    synchronized(session) {
    List itemsOrdered = cart.getItemsOrdered();
    if (itemsOrdered.size() == 0) {
    out.println("<H2><I>No items in your cart...</I></H2>");
    } else {
    // If there is at least one item in cart, show table
    // of items ordered.
    out.println
    ("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
    "<TR BGCOLOR=\"#FFAD00\">\n" +
    " <TH>Item ID<TH>Description\n" +
    " <TH>Unit Cost<TH>Number<TH>Total Cost");
    ItemOrder order;
    // Rounds to two decimal places, inserts dollar
    // sign (or other currency symbol), etc., as
    // appropriate in current Locale.
    NumberFormat formatter =
    NumberFormat.getCurrencyInstance();
    // For each entry in shopping cart, make
    // table row showing ID, description, per-item
    // cost, number ordered, and total cost.
    // Put number ordered in textfield that user
    // can change, with "Update Order" button next
    // to it, which resubmits to this same page
    // but specifying a different number of items.
    for(int i=0; i<itemsOrdered.size(); i++) {
    order = (ItemOrder)itemsOrdered.get(i);
    out.println
    ("<TR>\n" +
    " <TD>" + order.getItemID() + "\n" +
    " <TD>" + order.getShortDescription() + "\n" +
    " <TD>" +
    formatter.format(order.getUnitCost()) + "\n" +
    " <TD>" +
    "<FORM>\n" + // Submit to current URL
    "<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\"\n" +
    " VALUE=\"" + order.getItemID() + "\">\n" +
    "<INPUT TYPE=\"TEXT\" NAME=\"numItems\"\n" +
    " SIZE=3 VALUE=\"" +
    order.getNumItems() + "\">\n" +
    "<SMALL>\n" +
    "<INPUT TYPE=\"SUBMIT\"\n "+
    " VALUE=\"Update Order\">\n" +
    "</SMALL>\n" +
    "</FORM>\n" +
    " <TD>" +
    formatter.format(order.getTotalCost()));
    String checkoutURL =
    response.encodeURL("../Checkout.html");
    // "Proceed to Checkout" button below table
    out.println
    ("</TABLE>\n" +
    "<FORM ACTION=\"" + checkoutURL + "\">\n" +
    "<BIG><CENTER>\n" +
    "<INPUT TYPE=\"SUBMIT\"\n" +
    " VALUE=\"Proceed to Checkout\">\n" +
    "</CENTER></BIG></FORM>");
    out.println("</BODY></HTML>");
    }

    Sorry.
    actually this is my coding on the bottom.
    Pleease disregard my previous coding. I got the different one.
    My first approach is using <% %> around the whole doGet method such as:
    <%
    String[] ids = { "hall001", "hall002" };
    setItems(ids);
    setTitle("All-Time Best Computer Books");
    out.println("<HR>\n</BODY></HTML>");
    %>
    I am not sure how to break between code between
    return;
    and
    response.setContentType("text/html");
    Here is my coding:
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
         String[] ids = { "hall001", "hall002" };
         setItems(ids);
         setTitle("All-Time Best Computer Books");
    if (items == null) {
    response.sendError(response.SC_NOT_FOUND,
    "Missing Items.");
    return;
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>");
    CatalogItem item;
    for(int i=0; i<items.length; i++) {
    out.println("<HR>");
    item = items;
    if (item == null) {
    out.println("<FONT COLOR=\"RED\">" +
    "Unknown item ID " + itemIDs[i] +
    "</FONT>");
    } else {
    out.println();
    String formURL =
    "/servlet/coreservlets.OrderPage";
    formURL = response.encodeURL(formURL);
    out.println
    ("<FORM ACTION=\"" + formURL + "\">\n" +
    "<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\" " +
    " VALUE=\"" + item.getItemID() + "\">\n" +
    "<H2>" + item.getShortDescription() +
    " ($" + item.getCost() + ")</H2>\n" +
    item.getLongDescription() + "\n" +
    "<P>\n<CENTER>\n" +
    "<INPUT TYPE=\"SUBMIT\" " +
    "VALUE=\"Add to Shopping Cart\">\n" +
    "</CENTER>\n<P>\n</FORM>");
    out.println("<HR>\n</BODY></HTML>");

  • How to run this servlet? Please help!

    http://wrox.com/Books/Book_down.asp?section=11_4&isbn=1861002777&subject=&subject_id=
    Chapter 13 Source Code
    I can't seem to compile this WebMail.java file. I have TomCat and servlets.jar is in my classpath too running but to no avail! Do u manage to compile and run it? Can u guys tell me what did I do wrong? Here's my list of errors(not all).
    javac WebMail.java
    WebMail.java:4: cannot resolve symbol
    symbol : class HttpServlet
    location: class WebMail
    public class WebMail extends HttpServlet {
    ^
    WebMail.java:6: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class WebMail
    public void doGet(HttpServletRequest request
    ^
    WebMail.java:6: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class WebMail
    public void doGet(HttpServletRequest request
    WebMail.java:7: cannot resolve symbol
    symbol : class ServletException
    location: class WebMail
    throws ServletException, IOException {

    Direct link: ftp://ftp.wrox.com/Professional/2777/chap13.zip and a code snippet from that link:
    import javax.mail.*;
    import javax.mail.internet.*;
    public class WebMail extends HttpServlet{..}The sample code is not OK, as it does not define where to find HttpServlet or things like HttpServletRequest. Then even if your classpath is allright, the compiler still does not know what is 'HttpServlet'.
    If you look at http://java.sun.com/j2ee/tutorial/api/javax/servlet/http/HttpServlet.html you'll see that its full name is javax.servlet.http.HttpServlet. So either use the full names, like in
    public class WebMail
      extends javax.servlet.http.HttpServletand
    public void doGet(javax.servlet.http.HttpServletRequest ...)or (preferred) simply add the following line at the top of your code:
    import javax.servlet.http.*;Arjan.

  • How to achive this using servlet

    hi I am new to this technology... My requirement is , First I have to check whether that rebate_sku_num exists in the database or not.. If exits i need to update the row.. If now I have to insert the new row with values.. How to achive this..
    my screen contains 7 rows... in will increase.. for every submit.. i have to check with the database.. whether the rebate_sku_num exists or not.. help me out.. here is my code.. i am not sure how to format my code.. in future i will do it...
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId="";
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ;
    System.out.println("entering date is " +entryDate1) ;
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    // from here
    flag = true;
    for (int z = 0; z < rebate_sku_num.length && flag; z++) {
    try {
    flag=false;
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB where REBATE_SKU_NUM ='" + rebate_sku_num[z] + "'";
    System.out.println("AdjustmentServlet : doGet() : checking sku validity query = " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    while (resultset.next()) {
    RebateId = resultset.getString("REBATE_SKU_NUM");
    flag = true;
    if ((rebate_sku_num[z] != RebateId)) {
    System.out.println("get the values" +rebate_sku_num);
    System.out.println("get the values" + RebateId);
    Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
    "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
    "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
    "'" + rebate_sku_num[z] + "', " +
    "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
    "'" + amount[z] + "' , '" + user_name + "'" +
    ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
    ", '" + user_name + "'," +
    " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
    System.out.println("query is executed" +Query);
    }else if ((rebate_sku_num[z] == RebateId )){
    Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[z] + " where REBATE_SKU_NUM='" + rebate_sku_num[z] + "'";
    System.out.println("query is executed for updation" +Query);
    } else {
    System.out.println("AdjustmentServlet : doGet() : checking for sku validity : resultset null");
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in checking validity of SKU");
    exception1.printStackTrace();
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    try {
    if (DatabaseConnection.executeUpdate(Query) == 0) {
    System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
    DatabaseConnection.rollBack();
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    // break;
    } else {
    System.out.println("AddRebate : doPost() : update sucessfull");
    message = "Rebate Transactions has been updated.";
    flag = true;
    } catch (Exception ex) {
    System.out.println("AddRebate : doPost() : exception in update query");
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

    Oh and you can give me the dukes for helping you here:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=475828&tstart=0&trange=15

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • How to open a ".doc" file with ms word directly with this servlet?

    Here is a servlet for opening a word or a excel or a powerpoint or a pdf file,but I don't want the "file download" dialog appear,eg:when i using this servlet to open a word file,i want open the ".doc" file with ms word directly,not in IE or save.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class OpenWord extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request,response);
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
    String strFileName = req.getParameter("filename");
    int len = 0;
    String strFileType1 = "application/msword";
    String strFileType2 = "application/vnd.ms-excel";
    String strFileType3 = "application/vnd.ms-powerpoint";
    String strFileType4 = "application/pdf";
    String strFileType = "";
    if(strFileName != null) {
         len = strFileName.length();
         if(strFileName.substring(len-3,len).equalsIgnoreCase("doc")) {
              strFileType = strFileType1;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("xls")) {
              strFileType = strFileType2;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("ppt")) {
              strFileType = strFileType3;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("pdf")) {
              strFileType = strFileType4;
         } else {
              strFileType = strFileType1;
    if(strFileName != null) {
         ServletOutputStream out = res.getOutputStream();
         res.setContentType(strFileType); // MIME type for word doc
    //if uncomment below sentence,the "file download" dialog will appear twice.
         //res.setHeader("Content-disposition","attachment;filename="+strFileName);
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         String path = "d:\\"; //put a word or a excel file here,eg a.doc
         try {
         File f = new File(path.concat(strFileName));
         FileInputStream fis = new FileInputStream(f);
         bis = new BufferedInputStream(fis);
         bos = new BufferedOutputStream(out);
         byte[] buff = new byte[2048];
         int bytesRead;
         while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
         bos.write(buff, 0, bytesRead);
         } catch(NullPointerException e) {
         System.out.println ( "NullPointerException." );
         throw e;
         } catch(FileNotFoundException e) {
         System.out.println ( "FileNotFoundException." );
         throw e;
         } catch(final IOException e) {
         System.out.println ( "IOException." );
         throw e;
         } finally {
         if (bis != null)
         bis.close();
         if (bos != null)
         bos.close();

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

  • How to place a servlet file in Tomcat 5.0?

    Hi,
    i'm using Apache Tomcat 5.0 as myweb server.i don't know how to set the class path and where to place my servlet and html files,and how to run my servlet file.if anybody knows plz give me a detailed description abt this topic.

    Look at the directory structure of your Tomcat installation directory. You will see a webapps directory under that. The Tomcat installation comes with samples ready to run. Look at those and create a similar directory structure under webapps for your application. I don't think you need to worry about classpath. Tomcat should be taking care of all that if you create the proper directory structure.
    You run your servlet by specifying a url like:
    localhost:8080/servlets-examples/from a browser. This assumes that your installation is using port 8080 which I think is the norm for Tomcat. Here "servlets-examples" is the name of the directory you created. Actually Tomcat 5.0 comes with a "servlets-examples" application. This would be a good directory to look at. You could also run their examples to get a feel for it.
    If you are new to servlets, you'll probably have to get a book that explains how things need to be set up. You'll need to create a web.xml for your application. If you look at the servlets-examples directory under webapps, you'll see that it has a WEB-INF directory under it and that directory contains a file called web.xml as well as a sub-directory called classes. This structure is standard accross all application servers because it corresponds to the war (wars are specialized types of jars for web apps) file standard.

  • How to create a servlet  in PAR Application

    Hi Experts,
    I want to create a servlet in PAR application. This servlet should be capable of accessing the functions of other java files included in PAR Application. Servlet should be capable of accessing the functions say doContent(req, resp) of any class of PAR application.
    Is it possible to create Servlet in PAR application?
    I created one servlet but unable to declare its information in Deployment Descriptor.
    Because the deployment which is provide ie portalapp.xml doesnt allow us to write tags like <servlet-name>, <servlet-mapping>, <url-pattern> etc. These are necessary for declaration of servlet.
    So how can i write a complete working Servlet under PAR application?
    Please help and replies will be appreciated.

    Hi,
    Depending upon your usecase there are different ways to implement this logic.
    Check this for example (Read my answer in this post):
    https://forums.sdn.sap.com/thread.jspa?threadID=349151
    Also check these senarios:
    http://help.sap.com/saphelp_nw70/helpdata/en/42/9ddf20bb211d72e10000000a1553f6/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/42/9ddcc9bb211d72e10000000a1553f6/frameset.htm
    Also the delegation may be interesting for you:
    http://help.sap.com/saphelp_nw70/helpdata/en/a0/44b742cafec96ae10000000a155106/frameset.htm
    Greetings,
    Praveen Gudapati

  • How do i call servlet from javascript after validation the javascript

    Hi ,
    Can anyone tell me how to call a servlet after the javascript is being validated. Here is my code to validate javascript i need to call a servlet inorder to save the data into the same form. I tried calling through the action method in the form but its directly taking me to the servlet but not validating the form. Is there any way that i can validate the form first then call the servlet.
    Thanks in advance.
    <html>
    <head>
    <title>Online Blog</title>
    <script language ="javascript" type ="text/javascript">
    function myfunction()
    var mesg = "";
    var dmesg = "";
    var dnumber = 0;
    var number = 0
    var Blogstr = document.onlineblog.BlogName;
    var Fnamestr = document.onlineblog.FirstName;
    var Lnamestr = document.onlineblog.LastName;
    var Datestr = document.onlineblog.Dateformat;
    var Imagestr = document.onlineblog.uploadimage;
    var Imageval = Imagestr.value;
    var flength = parseInt(Imageval.length) - 3;
    var fext = Imageval.substring(flength,flength + 3);
    var Dateval = Datestr.value;
    var Dformat = /^\d{2}\/\d{2}\/\d{4}/; //checks the date format.
    //splits date into mm, dd , yyyy format.
    var m = Dateval.split("/")[0];
    var d = Dateval.split("/")[1];
    var y = Dateval.split("/")[2];
    //Get today's date (removes time).
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1;
    var yyyy = today.getFullYear();
    //checks if month and date are displayed in mm, dd format and if not sets to mm,dd.
    if (mm <10)
    mm = '0'+mm;
    if (dd <10)
    dd = '0'+dd;
    //checks if name of the blog is empty
    if(Blogstr.value == "")
    number = number+1;
    mesg += "\n" + number + "Name of the blog";
    //checks if value of Frist Name is empty;
    if(Fnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "First Name";
    //checks if value of Last Name is empty;
    if(Lnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Last Name";
    //checks if value of date is empty;
    if(Datestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Date of mm/dd/yyyy format";
    //checks if value of image field is empty;
    if(Imagestr.value == "")
    number = number+1;
    mesg += "\n" + number + "select an image";
    //displays all the error messages.
    if (number > 0)
    alert ("Please enter the following" + mesg);
    return false;
    //checks if entered date format is mm/dd/yyyy
    if(!Dformat.test(Dateval))
    dnumber = dnumber +1;
    dmesg += "\n" + dnumber + "please enter a valid date(mm/dd/yyyy)";
    //checks if date is greater than 12 and is 2 digits.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid month(mm)";
    //checks if month has 31 or 30 days and is in dd format.
    if (((d>30) && (d<100) && (m == 04 || m == 06 || m == 9 || m == 11)) || ((m == 01 || m == 03 || m == 05 || m == 07 || m == 08 || m == 10 || m==12) && (d >31) && (d<100)) || d == 0)
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if month has 28 or 29 days and wheather is a leap year or not.
    if((m == 02 && d>29 && y%4 == 0) || (m == 02 && d>28 && y%4 != 0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if entered date is prior to the current date.
    if((m == mm && d == dd && y == yyyy) || (y > yyyy)|| (d>=dd && m>=mm && m<=12 && y==yyyy) || (d<=dd && m>mm && y == yyyy && m<=12))
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Please enter a date prior to the current date";
    if (y == 0 || y < 1000 || y>9999) //checks if year is zero and is a 4 digit number.
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Enter a valid year(yyyy)";
    //checks if image format is jpg or gif.
    if(fext != "jpg" && fext != "gif")
    dnumber = dnumber + 1
    dmesg += "\n" + dnumber + "You can only upload gif or jpg images.";
    if(dnumber>0)
    alert("please check the followin error messages"+dmesg);
    return false;
    </script>
    <style type="text/css">
    .style1 {color: #FF0000}
    body {
         background-color: #FFCCFF;
    h2 {
         color: #CC3399;
    h1 {
         color: cc3399;
    .style2 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
    .style5 {color: #000000; font-family: "Times New Roman", Times, serif;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body>
    <h1 align="center">Webloggers space</h1>
    <p align="center">Home
    <p>
    <h4> Please enter the following details to register.</h4>
    <p> <b>Note:</b> All fields marked with <span class="style1">*</span>(astrick)
    are compulsory.</p>
    <form action="servlet/BlogServlet" name="onlineblog" onsubmit = "return myfunction()" method="post">
    <table width="60%" border="0" cellspacing="5" cellpadding="2">
    <tr>
    <td><span class="style1">*</span>Name of the Blog</td>
    <td><input type="text" name="BlogName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>First Name</td>
    <td><input type="text" name="FirstName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Last Name</td>
    <td><input type="text" name="LastName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Date(mm/dd/yyyy)</td>
    <td><input type="text" name="Dateformat"/></td>
    </tr>
    <tr>
    <td>Category</td>
    <td><select name="catagory" size="1">
    <option></option>
    <option>Business</option>
    <option>Education</option>
    <option>Entertainment</option>
    <option>Food</option>
    <option>Hobbies</option>
    <option>Personal</option>
    <option>Politics</option>
    <option>Sports</option>
    </select></td>
    </tr>
    <tr>
    <td>Enter your text here:</td>
    <td><textarea name="textarea" cols="45" rows="5"></textarea></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Upload Image <span class="style5">(.jpg
              or .gif)</span></td>
    <td><input type="file" name="uploadimage" /></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" value="save">
    <input type="reset" name="reset" value="Reset" /></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Your javascript code contains a syntax error. That's why the function isn't being called. Take a look at this line in your code.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))Notice the space between > and =. Remove that space.
    m >= 100

  • How to create a servlet and write its details in DD in PAR Application

    Hi Experts,
    I want to create a servlet in PAR application. This servlet should be capable of accessing the functions of other java files included in PAR Application. Servlet should be capable of accessing the functions say doContent(req, resp) of any class of PAR application.
    Is it possible to create Servlet in PAR application?
    I created one servlet but unable to declare its information in Deployment Descriptor.
    Because the deployment which is provide ie portalapp.xml doesnt allow us to write tags like <servlet-name>, <servlet-mapping>, <url-pattern> etc. These are necessary for declaration of servlet.
    So how can i write a complete working Servlet under PAR application?
    Please help and replies will be appreciated.

    Hi Pankaj,
    I don't think it is possible to write Servlet in portal applications.
    I guess in Portal Application Projects we can develop portal components and portal services only.
    Thanks and regards,
    -Madhu

  • How to create the servlet as acontroller  and how to use it

    how to create the servlet as acontroller and how to use it

    >
    John
    Please update your forum profile with a real handle instead of "914824".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I am going to have over 50 buttons in a page, Why? This would be a most unusual UI paradigm. I've never seen such a page, which suggests that whatever you want to do is normally done another way. Please explain the requirement in more detail.
    just wanted to know if its possible to do something like this in java.
    Java is not used in programming APEX UI behaviour. Java and JavaScript may share initial syllables, but they are not closely related.
    It's possible to achieve a great deal in JavaScript, but a clear definition of the requirements is necessary. Do you mean the buttons should be dynamically generated? If so, yes, this is possible in JavaScript. What would drive the process?
    Also, i would like to have dynamic action on it, for example, when the button is pressed, fill a string of text into other items(text field) within the page. Without more detail its not possible to make any specific suggestions. For example, I certainly would not want to create 50+ individual dynamic actions relating to different buttons.

  • How to start a Servlet on the Startup of my application

              Hai al,
              I have an requirtment abt an application on which i need to start a servlet
              when my application starts. i am blank abt how to do this. can any body help me
              to do ths. Please mention the steps involved in doing this.
              Cheers
              Senthil Kumar M Rangaswamy
              

    In web.xml deployment descriptor, specify <servlet><load-on-startup>1</load-on-startup></servlet>
    element.
    thanks,
    Deepak
    "Senthil Kumar M Rangaswamy" <[email protected]> wrote:
    >
    Hai all,
    I have a requirment in my application, that i need to start a servlet
    (automatically)
    when i start my application, am blank in how to do ths can any body help
    me to
    achive ths. waitiing for a ur replys.
    cheers
    Senthil kumar MR

  • How to restart the Servlet Engine?

    Hi
    I am configurating a WebDAV repository in KM
    I am required to restart the Servlet Engine.
    Can anyone please explain me how to restart the servlet engine.
    Thanks in advance
    -madhu

    Basically it means to restart the Java engine!
    On way to do this is to use the NetWeaver Administrator tool (http://portal:port/nwa) and navigate to Administration -> Systems -> <Your SID> and then you will see your dispatcher and server nodes. Just restart the server0..n nodes.
    Cheers

  • How to determine the Servlet which current request is mapped to

    Hello folks,
    having a filter, i want to discover the servlet (if any) which will serve the current request. I want to have it before the chain execution. Does someone has an idea how to accomplish this using Servlet API? The old API provided the getServlet(String name) method for this task. Here the sample code:
    Servlet servingInstance = discoverServlerForRequest(request); //i look for implementation of this method
    chain.doFilter(request,response);I know that it would be very easy to get the servlet AFTER processing the chain, but the clue for me is to get it before.
    Maybe Tomcat has implemented some special servlet context attributes to map it?
    any hint appreciated!
    thanks

    its possible, for sure. but then I need two filters to achieve it. I'll post my solution later, if there wont be any other ideas. I know that tomcat maps many objects by attributes...maybe there is a key for it.

  • How Can I Run Servlet in tomcat

    Hi My Friends
    Please can any one tell me how can I Run Servlet in tomcat using my own Virtual Directory � my ask about , what is the structure it must be make it in the hierarchy of the sub folder of Virtual Directory , and in watch folder it must be put the servlet files and there is any change it must be make it in any file of the tomcat files and so on
    Please give my full details about this thing
    And thanks

    What version of Tomcat are u using?

Maybe you are looking for

  • HT4527 I am trying to transfer music to a new computer using homeshare but it is not working.

    I can see the library from the "old" computer and can "select all" as the online help suggests. There is not an "import" button on the bottom right of itunes as the online help suggests and I don't see any options on the drop down menus to do this. 

  • Calculating between different s

    Can I and if so, how would I creat a formula a total difference between numbers on different subject area reports - for instance: Total Nbr Trxs (*Account History* and filtered on a Field containing "Lost") minus Total Trxs (*Opportunity History* and

  • BW 7.3 and ECC 6.05 Problem with BI Content Activation Objects

    Hi Experts, I'm trying to activate the Business Content 0HE (Higher educations) and using the procedure suggested by the document "Campus BW 7 for Content Management". I have done what the manual indicates. 1. Enable data sources in the source system

  • Does anyone know how to copyright mark photographs in iphoto?

    Does anyone know how to copyright mark photographs in iphoto?

  • New Trackpads

    1.) What types of things can you do with the new trackpads? Can you zoom in and out of any image in Preview and move it around like you can do on the iPhone? What other applications does it work with? 2.) How sensitive is the track pad? Does it seem