Set a new servlet to form.action in a Javascript method

Hi!
I have a JSP page with a form where I set a servlet to call on submit in the action attribute. This servlet is supposed to be called when pressing the submit button at the end of the page.
In JSP:
<form action="<c:url value="/commitment"/>" method="POST" name="CommitmentAdd">
My problem is that I have a select box inside my form where I use 'onchange' to call a Javascript method, and in that method I want to set another servlet to the forms action (using the servlet-mapping url-pattern name in my web.xml file).
(I want the JSP page to change due to what you choose in the select box and I'd like to have that code in a separate servlet.)
In Javascript:
document.CommitmentAdd.action="/commitmentAddReload";
document.CommitmentAdd.submit();
When the Javascript method is called I get the error:
"The requested resource (/commitmentAddReload) is not available."
How can I set a new servlet to be found and called on submit?
Thanks,
Asa

Try putting the whole URL in.

Similar Messages

  • Problems with file uploading servlet, the form action doesnt capture url

    Hi, i have one problem. I am working on a project , i have created a servlet that takes uploaded files and processses them and links them back to user to download. The servlet works perfectly from my computer, I am using apache-tomcat-6.0.16 and java 1.6 , I have two forms called encrypt.html and decrypt.html, I will post both of them, now the problem is when somebody access it on the internet while i am running apache, they get a connection was reset on a firefox browser and same stuff on Internet Explorer.
    i have checked my server logs and saw nothing unusual there, So please if you can help me, it is my project.
    I am pasting html file and error message that other users where getting remotely.
    <html>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
    <title>Stego Form</title>
    <link rel='STYLESHEET' type='text/css' href='encrypt.css'>
    </head>
    <body>
    <center>
    <form name='encrypt' enctype='multipart/form-data' method='POST' action='http://localhost:8080/examples/temp2
    ' accept-charset='UTF-8'>
    <input type='hidden' name='sfm_form_submitted' value='yes'>
    </input>
    <input type='hidden' name='eord' value='e'>
    <select name='encryption' size='1'>
             <option value='Select an encryption' selected>
             Select an encryption
             </option>
             <option value='DES'>
             DES
             </option>
             <option value='Tripple DES'>
             Tripple DES
             </option>
    </select>
             <input type='file' name='overt' size='20'>
             <input type='file' name='covert' size='20'>
             <input type='submit' name='submit' value='Submit'>
    </form>
    </center>
    </body>
    </html>so it works for me even if i access the page with my ip , but for others it doesnt work,
    now the user got this xhtml page that i will show, i cant find attach button so i am pasting here.
    here is the servlet coding
    import java.io.*;
    import java.util.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    public class temp2 extends HttpServlet
        FileInputStream fin;
        String filenames[] = new String[2],fieldname,fieldval;
        String keyfile,IVfile;
        String names[] = new String[2];
        public temp2()
            super();
        @Override
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
            doPost(request, response);
        @Override
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
            String eord="";
            List lst = null;
            boolean isMultiPart = ServletFileUpload.isMultipartContent(request);
            if (!isMultiPart) // check whether the post request is actually multipart
                System.out.println("ERROR NOT MULTIPART");
                System.exit(0);
            DiskFileItemFactory fif = new DiskFileItemFactory();
            ServletFileUpload sfu = new ServletFileUpload(fif);
            sfu.setSizeMax(10000000);
            try {  lst = sfu.parseRequest(request);  }
            catch (FileUploadException ex)
            { System.out.println("ERROR IN PARSING FILES" + ex); System.exit(0);  }
            if(lst.isEmpty())  // check whether request is empty
                System.out.println("ERROR LIST SIZE NOT GOOD : " + lst.size());
                System.exit(0);
            Iterator x = lst.iterator();
            int i = 0;
            FileItem f = (FileItem)x.next();
            f = (FileItem)x.next();
            System.out.println(f.getFieldName());
            if(f.getFieldName().equalsIgnoreCase("eord")) // check hidden field to know the case : encrypt or decrypt
                eord = f.getString();
                System.out.println(f.getString());
            else // if it is not first field exit
                System.out.println("Invalid FORM");
                System.exit(0);
            f = (FileItem)x.next(); // next field
            if(f.getFieldName().equalsIgnoreCase("encryption")) // type of encryption des / tdes
                fieldname = f.getFieldName();
                fieldval = f.getString();
                System.out.println(f.getString());
            if(eord.equalsIgnoreCase("e")) // if it is encryption form only file required
                while(x.hasNext())
                    f = (FileItem)x.next();
                    if(!f.isFormField())
                        int check = f.getName().lastIndexOf(File.separator);
                        System.out.println(File.separator);
                        if(check==-1)
                            System.out.println(f.getName());
                            System.out.println("Unsupported browser : " + check);
                            System.exit(0);
                        File ff = new File("e:\\apache\\webapps\\temp\\"+f.getName().substring(check));
                        names[i] = ff.getName(); // original file names
                        try
                            f.write(ff);
                            filenames[i] = ff.getAbsolutePath();
                        // renamed    
                            ff.deleteOnExit();
                        }catch(Exception e) {System.out.println("Error writing file"+ ff.getAbsolutePath()); System.exit(0);}
                        i++;
                    try { System.in.read(); } catch(Exception e) {}
                }// endwhile
                if(fieldval.equalsIgnoreCase("DES"))
                    System.out.println("DES 1"+filenames[1]);
                    javades o = new javades(filenames[1]); // the file to be encrypted   
                    filenames[1] = "e:\\apache\\webapps\\temp\\files\\" + names[1];
                    System.out.println("should be original" + filenames[1]);
                else if(fieldval.equalsIgnoreCase("Tripple DES"))
                    javatdes o = new javatdes(filenames[1]);
                    filenames[1] = "e:\\apache\\webapps\\temp\\files\\" + names[1];
                    System.out.println(filenames[1]);
                System.out.println("Calling stego");
                filenames[0] = "e:\\apache\\webapps\\temp\\" + names[0];
                System.out.println("file 1 "+ filenames[0]);
                System.out.println("file 2"+ filenames[1]);
                try { System.in.read(); } catch(Exception e) {}
                stego s = new stego(filenames[0],filenames[1]);
                System.out.println("mainext " + s.mainext);
                // encryption done, and new files are loaded, now lets hide
                if(s.mainext.equalsIgnoreCase("wav"))
                    s.encodewav();
                    System.out.println("Encoded wave");
                else if(s.mainext.equalsIgnoreCase("bmp"))
                    System.out.println("Encoded bmp");
                    s.encodebmp();
                System.out.println("done !");
                PrintWriter pr = response.getWriter();
                pr.println("Greetings , Your work is done and saved, now download the following files");
                pr.println("The secret key file is needed for getting back your hidden file, so download that too");
                pr.write("<a href=\"/temp/files/IV.txt\">click here</a>");
                pr.write("<br/><a href=\"/temp/files/key.txt\">click here</a>");
                pr.write("<br/><a href=\"/temp/files/"+names[0]+"\">click here</a>");
                return;
            // if it is decryption case
            else if(eord.equalsIgnoreCase("d"))
                while(x.hasNext())
                    f = (FileItem)x.next();
                    if(!f.isFormField())
                        int check = f.getName().lastIndexOf(File.separator);
                        System.out.println(File.separator);
                        if(check==-1)
                            System.out.println(f.getName());
                            System.out.println("Unsupported browser : " + check);
                            System.exit(0);
                        File ff = new File("e:\\apache\\webapps\\temp\\"+f.getName().substring(check));
    // else if ladder to store paths of stegofile keyfile and IVfile                   
                        if(f.getFieldName().equalsIgnoreCase("stegofile"))
                            filenames[0] = ff.getAbsolutePath();
                        else if(f.getFieldName().equalsIgnoreCase("keyfile"))
                            keyfile = ff.getAbsolutePath();
                        else if(f.getFieldName().equalsIgnoreCase("IVfile"))
                            IVfile = ff.getAbsolutePath();
                        try
                            f.write(ff); // writes whole file at once
                        }catch(Exception e) {System.out.println("Error writing file"); System.exit(0);}
                }// endwhile
                System.out.println("Calling stego");
                System.out.println("file 1 "+ filenames[0]);
                stego s = new stego(filenames[0]);
                System.out.println("mainext " + s.mainext);
                if(s.mainext.equalsIgnoreCase("wav"))
                    s.decodewav();
                    System.out.println("Encoded wave");
                else if(s.mainext.equalsIgnoreCase("bmp"))
                    s.decodebmp();
                    System.out.println("Encoded bmp");
                System.out.println("done !");
                ////// hidden file has been retrieved , now lets decrypt it
                System.out.println("ext " + s.ext);
                filenames[0] = "e:\\apache\\webapps\\temp\\"+s.filename;
                System.out.println(filenames[0]);
                System.out.println(keyfile);
                System.out.println(IVfile);
                if(fieldval.equalsIgnoreCase("DES"))
                    javades o = new javades(filenames[0],keyfile,IVfile); // the file to be encrypted   
                    filenames[0] = "e:\\apache\\webapps\\temp\\" + ( new File(filenames[0]).getName());
                    System.out.println("should be original" + filenames[0]);
                else if(fieldval.equalsIgnoreCase("Tripple DES"))
                    javatdes o = new javatdes(filenames[0],keyfile,IVfile);
                    filenames[0] = "e:\\apache\\webapps\\temp\\" + ( new File(filenames[0]).getName());
                    System.out.println(filenames[0]);
                PrintWriter pr = response.getWriter();
                pr.write("Greetings, you have successfully retrieved your hidden file, now download it from here <br>");
                pr.write("<a href=\"http://localhost:8080/temp/files/" + (new File(filenames[0]).getName())+"\">Click here</a>");
    }and here is the xhtml file the user receives, whe he clicks the submit button,
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html [
      <!ENTITY % htmlDTD
        PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "DTD/xhtml1-strict.dtd">
      %htmlDTD;
      <!ENTITY % netErrorDTD
        SYSTEM "chrome://global/locale/netError.dtd">
      %netErrorDTD;
    <!ENTITY loadError.label "Problem loading page">
    <!ENTITY retry.label "Try Again">
    <!-- Specific error messages -->
    <!ENTITY connectionFailure.title "Unable to connect">
    <!ENTITY connectionFailure.longDesc "&sharedLongDesc;">
    <!ENTITY deniedPortAccess.title "This address is restricted">
    <!ENTITY deniedPortAccess.longDesc "">
    <!ENTITY dnsNotFound.title "Server not found">
    <!ENTITY dnsNotFound.longDesc "
    <ul>
      <li>Check the address for typing errors such as
        <strong>ww</strong>.example.com instead of
        <strong>www</strong>.example.com</li>
      <li>If you are unable to load any pages, check your computer's network
        connection.</li>
      <li>If your computer or network is protected by a firewall or proxy, make sure
        that &brandShortName; is permitted to access the Web.</li>
    </ul>
    ">
    <!ENTITY fileNotFound.title "File not found">
    <!ENTITY fileNotFound.longDesc "
    <ul>
      <li>Check the file name for capitalization or other typing errors.</li>
      <li>Check to see if the file was moved, renamed or deleted.</li>
    </ul>
    ">
    <!ENTITY generic.title "Oops.">
    <!ENTITY generic.longDesc "
    <p>&brandShortName; can't load this page for some reason.</p>
    ">
    <!ENTITY malformedURI.title "The address isn't valid">
    <!ENTITY malformedURI.longDesc "
    <ul>
      <li>Web addresses are usually written like
        <strong>http://www.example.com/</strong></li>
      <li>Make sure that you're using forward slashes (i.e.
        <strong>/</strong>).</li>
    </ul>
    ">
    <!ENTITY netInterrupt.title "The connection was interrupted">
    <!ENTITY netInterrupt.longDesc "&sharedLongDesc;">
    <!ENTITY netOffline.title "Offline mode">
    <!ENTITY netOffline.longDesc "
    <ul>
      <li>Uncheck "Work Offline" in the File menu, then try again.</li>
    </ul>
    ">
    <!ENTITY netReset.title "The connection was reset">
    <!ENTITY netReset.longDesc "&sharedLongDesc;">
    <!ENTITY netTimeout.title "The connection has timed out">
    <!ENTITY netTimeout.longDesc "&sharedLongDesc;">
    <!ENTITY protocolNotFound.title "The address wasn't understood">
    <!ENTITY protocolNotFound.longDesc "
    <ul>
      <li>You might need to install other software to open this address.</li>
    </ul>
    ">
    <!ENTITY proxyConnectFailure.title "The proxy server is refusing connections">
    <!ENTITY proxyConnectFailure.longDesc "
    <ul>
      <li>Check the proxy settings to make sure that they are correct.</li>
      <li>Contact your network administrator to make sure the proxy server is
        working.</li>
    </ul>
    ">
    <!ENTITY proxyResolveFailure.title "Unable to find the proxy server">
    <!ENTITY proxyResolveFailure.longDesc "
    <ul>
      <li>Check the proxy settings to make sure that they are correct.</li>
      <li>Check to make sure your computer has a working network connection.</li>
      <li>If your computer or network is protected by a firewall or proxy, make sure
        that &brandShortName; is permitted to access the Web.</li>
    </ul>
    ">
    <!ENTITY redirectLoop.title "The page isn't redirecting properly">
    <!ENTITY redirectLoop.longDesc "
    <ul>
      <li>This problem can sometimes be caused by disabling or refusing to accept
        cookies.</li>
    </ul>
    ">
    <!ENTITY unknownSocketType.title "Unexpected response from server">
    <!ENTITY unknownSocketType.longDesc "
    <ul>
      <li>Check to make sure your system has the Personal Security Manager
        installed.</li>
      <li>This might be due to a non-standard configuration on the server.</li>
    </ul>
    ">
    <!ENTITY sharedLongDesc "
    <ul>
      <li>The site could be temporarily unavailable or too busy. Try again in a few
        moments.</li>
      <li>If you are unable to load any pages, check your computer's network
        connection.</li>
      <li>If your computer or network is protected by a firewall or proxy, make sure
        that &brandShortName; is permitted to access the Web.</li>
    </ul>
    ">
      <!ENTITY % globalDTD
        SYSTEM "chrome://global/locale/global.dtd">
      %globalDTD;
    ]>
    <!-- ***** BEGIN LICENSE BLOCK *****
       - Version: MPL 1.1/GPL 2.0/LGPL 2.1
       - The contents of this file are subject to the Mozilla Public License Version
       - 1.1 (the "License"); you may not use this file except in compliance with
       - the License. You may obtain a copy of the License at
       - http://www.mozilla.org/MPL/
       - Software distributed under the License is distributed on an "AS IS" basis,
       - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
       - for the specific language governing rights and limitations under the
       - License.
       - The Original Code is mozilla.org code.
       - The Initial Developer of the Original Code is
       - Netscape Communications Corporation.
       - Portions created by the Initial Developer are Copyright (C) 1998
       - the Initial Developer. All Rights Reserved.
       - Contributor(s):
       -   Adam Lock <[email protected]>
       -   William R. Price <[email protected]>
       -   Henrik Skupin <[email protected]>
       -   Jeff Walden <[email protected]>
       - Alternatively, the contents of this file may be used under the terms of
       - either the GNU General Public License Version 2 or later (the "GPL"), or
       - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
       - in which case the provisions of the GPL or the LGPL are applicable instead
       - of those above. If you wish to allow use of your version of this file only
       - under the terms of either the GPL or the LGPL, and not to allow others to
       - use your version of this file under the terms of the MPL, indicate your
       - decision by deleting the provisions above and replace them with the notice
       - and other provisions required by the LGPL or the GPL. If you do not delete
       - the provisions above, a recipient may use your version of this file under
       - the terms of any one of the MPL, the GPL or the LGPL.
       - ***** END LICENSE BLOCK ***** -->
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Problem loading page</title>
        <link rel="stylesheet" href="temp2_files/netError.css" type="text/css" media="all"/>
        <!-- XXX this needs to be themeable -->
        <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAICSURBVHjaYvz//z8DJQAggJhwiDPvnmlzc2aR0O+JGezt+AwACCCsBhxfYhn59N41FWtXIxZOLu70niRGXVwGAAQQNgNYHj96O8HaWYdJW5ubwd4/mI2Ng7sblwEAAYRhwMm1URk/vn4SUNWVYGD8+YZBXZOZm5OLzRjoCmNsBgAEEKoBN82Y7l851GLrqMjM8Oc7A8O/3wwMP54wuAQFCXNycUzGZgBAAKEYcOaKZO2/f//5FbUVgBrfMoRVcgHpNwyKGjKMXDwCan0prFboBgAEELIBzDcvXyy2cVZhYPj9GWj7H4jo/38MDJ9OMDj7O/KzsjH3oxsAEEBwA/bNNipiZf7FI6cqwcDw8x2qqp8fGORUpVn4BEXlgGHhhCwFEEAwA9gfP3hdZ+Oizcjw+wvCdjgAuuLrFQbXIH9hTm7uqcgyAAEENuD4ctcebm5mbikFYRTbV7V/Q6j88Z5BSuY7q4CQgAjQFR4wYYAAAhtw89L5ZFsnRaDtn4CW/YXrAQcisit+PGVwDgrnZ2NnnwATBQggpsNLvGYLCAmxi8tLARWg+h3FBVBXSEj/ZZWQkRcCuiIQJAQQQCyvnj5KMDTkZ2JgYmRg4FchnHv+vmEwttLmeXT3VjKQtx4ggFgk5TXebV63UfT3ijOMxOZAVlZWdiB1EMQGCCBGSrMzQIABAFR3kRM3KggZAAAAAElFTkSuQmCC"/>
        <script type="application/x-javascript"><![CDATA[
          // Error url MUST be formatted like this:
          //   moz-neterror:page?e=error&u=url&d=desc
          // Note that this file uses document.documentURI to get
          // the URL (with the format from above). This is because
          // document.location.href gets the current URI off the docshell,
          // which is the URL displayed in the location bar, i.e.
          // the URI that the user attempted to load.
          function getErrorCode()
            var url = document.documentURI;
            var error = url.search(/e\=/);
            var duffUrl = url.search(/\&u\=/);
            return decodeURIComponent(url.slice(error + 2, duffUrl));
          function getDescription()
            var url = document.documentURI;
            var desc = url.search(/d\=/);
            // desc == -1 if not found; if so, return an empty string
            // instead of what would turn out to be portions of the URI
            if (desc == -1) return "";
            return decodeURIComponent(url.slice(desc + 2));
          function retryThis()
            // Session history has the URL of the page that failed
            // to load, not the one of the error page. So, just call
            // reload(), which will also repost POST data correctly.
            try {
              location.reload();
            } catch (e) {
              // We probably tried to reload a URI that caused an exception to
              // occur;  e.g. a non-existent file.
          function initPage()
            var err = getErrorCode();
            // if it's an unknown error or there's no title or description
            // defined, get the generic message
            var errTitle = document.getElementById("et_" + err);
            var errDesc  = document.getElementById("ed_" + err);
            if (!errTitle || !errDesc)
              errTitle = document.getElementById("et_generic");
              errDesc  = document.getElementById("ed_generic");
            var title = document.getElementById("errorTitleText");
            if (title)
              title.parentNode.replaceChild(errTitle, title);
              // change id to the replaced child's id so styling works
              errTitle.id = "errorTitleText";
            var sd = document.getElementById("errorShortDescText");
            if (sd)
              sd.textContent = getDescription();
            var ld = document.getElementById("errorLongDesc");
            if (ld)
              ld.parentNode.replaceChild(errDesc, ld);
              // change id to the replaced child's id so styling works
              errDesc.id = "errorLongDesc";
            // remove undisplayed errors to avoid bug 39098
            var errContainer = document.getElementById("errorContainer");
            errContainer.parentNode.removeChild(errContainer);
        ]]></script>
      </head>
      <body dir="ltr">
        <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
        <!-- PAGE CONTAINER (for styling purposes only) -->
        <div id="errorPageContainer">
          <!-- Error Title -->
          <div id="errorTitle">
            <h1 id="errorTitleText">The connection was reset</h1>
          </div>
          <!-- LONG CONTENT (the section most likely to require scrolling) -->
          <div id="errorLongContent">
            <!-- Short Description -->
            <div id="errorShortDesc">
              <p id="errorShortDescText">The connection to the server was reset while the page was loading.</p>
            </div>
            <!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
            <div id="errorLongDesc">
    <ul>
      <li>The site could be temporarily unavailable or too busy. Try again in a few
        moments.</li>
      <li>If you are unable to load any pages, check your computer's network
        connection.</li>
      <li>If your computer or network is protected by a firewall or proxy, make sure
        that Firefox is permitted to access the Web.</li>
    </ul>
    </div>
          </div>
          <!-- Retry Button -->
          <xul:button xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="errorTryAgain" label="Try Again" oncommand="retryThis();"/>
        </div>
        <!--
        - Note: It is important to run the script this way, instead of using
        - an onload handler. This is because error pages are loaded as
        - LOAD_BACKGROUND, which means that onload handlers will not be executed.
        -->
        <script type="application/x-javascript">initPage();</script>
      </body>
    </html>thank you for your prompt reply in advance,
    Regards,
    Mihir Pandya

    Hi, thank you for your replies, I found out few things about my servlet, and its portability
    and i have few questions, although i marked this topic as answered i guess its ok to post
    I am using javax.servlet.context.tempdir to store my files in that servletcontext temporary directory. But i dont know how to give hyperlink
    of the modified files to the user for them to download the modified files.
    What i am using to get the tempdir i will paste
    File baseurl = (File)this.getServletContext().getAttribute("javax.servlet.context.tempdir");
    System.out.println(baseurl);
    baseurl = new File(baseurl.getAbsolutePath()+File.separator+"temp"+File.separator+"files");
    baseurl.mkdirs();so i am storing my files in that temp/files folder and the servlet processes them and modifies them, then how to present them as
    links to the user for download ?
    and as the servlet is multithreaded by nature, if my servlet gets 2 different requests with same file names, i guess one of them will be overwritten
    And i want to create unique directory for each request made to the servlet , so file names dont clash.
    one another thing is that i want my servlet to be executed by my <form action> only, I dont want the user to simply type url and trigger the servlet
    Reply A.S.A.P. please..
    Thanks and regards,
    Mihir Pandya

  • Run servlet from form action tag

    This is my first post to this forum, thanks in advance for any and all help!
    I'm utilizing Tomcat 4.0.1. I've got the following form tag within my JSP:
    <form name="orderForm" method="GET" action="/myAppName/myServletName">
    I've made the context entry for myAppName within ..tomcat/conf/server.xml.
    I've got a properly formatted ..tomcat/webapps/myAppName/web-inf/web.xml
    When submitting the form, Tomcat immediately reports that the resource (myServletName) is unavailable.
    I've download the bookstore sample app from Sun; it is working properly.
    Any idea what I'm missing here?
    The bookstore app calls the servlet from a hyperlink rather that a form action. Do JSP's treat forms differently when calling servlets?
    Thanks again for any assistance.
    Bruce

    Yes, my .class files in in Tomcathome/webapps/appname/web-inf/classes
    If I try and call the servlet from the Address box of the browser, I get the same error listed above.
    Here is the contents of my Tomcathome/webapps/appname/web-inf/web.xml:
    <-- entry begins here
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
         <servlet>
              <servlet-name>myServletName</servlet-name>
              <servlet-class>myServletName</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>myServletName</servlet-name>
              <url-pattern>/myServletName</url-pattern>
         </servlet-mapping>
    </web-app>
    < -- entry ends here
    Here is the entry I've made in Tomcathome/conf/server.xml:
    <--entry begins here
    <Context path="/appName" docBase="appName" debug="0" reloadable="true" />
    <--entry ends here
    The only Tomcat related entry in my classpath is:
    d:\jakarta-tomcat-4.0.1\common\lib\servlet.jar;
    Again, thanks for all your assistance...this is driving me nuts (granted, it wasn't a long trip!)
    Bruce

  • How to specify the servlet in the ACTION field in FORM in jsp, html pages?

    I have problem when I return back to the page prova3.html from the servlet because in the address bar it give me this path:
    http://192.168.161.209:8988/Workspace3-Project1-context-root/servlet/servlet/Servlet1
    two times servlet/ why? and what I have to put in the action field?
    This is my form in page prova3.html:
    <form action="servlet/Servlet1" method="post" id="search" style="font: bold 80% Arial,sans-serif; color: #334d55;" >
    <input type="hidden" name="pagina" value="1"/>
         user<input name="username" type="text" size="10" style="font-size: 12px;"/> 
    password<input name="password" type="password" size="10" style="font-size: 12px;"/>
         <input name="login" type="submit" value="Login" style="font-size: 12px; font-family: Arial,sans-serif;"/>
    </form>
    The redirection form servlet to pages is:
    private void toProvaPage(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException {
    RequestDispatcher rd = getServletContext().getRequestDispatcher(
    "/prova.jsp");
    rd.forward(request, response);
    private void toIndexPage(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException {
    RequestDispatcher rd = getServletContext().getRequestDispatcher(
    "/prova3.html");
    rd.forward(request, response);
    Thanks, but I can solve this problem.

    This is my web.xml file where the mapping is specified, this is the thing that I can't understand.
    <web-app>
    <description>Empty web.xml file for Web Application</description>
    <display-name>public_html</display-name>
    <servlet>
    <servlet-name>Servlet1</servlet-name>
    <servlet-class>servlet.Servlet1</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Servlet1</servlet-name>
    <url-pattern>/servlet1</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>35</session-timeout>
    </session-config>
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain</mime-type>
    </mime-mapping>
    </web-app>
    Thanks

  • Set form action

    Hi everybody
    I want to set the actioan of my form in a jsp page dependent on the input value from a textfield ,what should i do?
    by thanks
    Javaneh

    Use Javascript.

  • Print Preview in RFx does not show new Adobe Interactive Form

    Hello Experts,
    I am trying to assign a standard Adobe Interactive form as the output form for SRM RFQ.  I have carried out the following steps in customising under "Define Actions for Document Output".
    - Selected bid invitation Action Profile = BBP_PD_BID
    - Go to "Processing Types"
    - Create a new Processing Type called "External Communication"
    - Set the following values to the new processing type:
         - Form Name = BBP_BID_INV_ADB
         - Form Type = P PDF-Based Forms
         - Format = BBP_BID_INV_ADB_MAI
         - Personalization Type = 5 - Recipeient Variable Replacement
    - Save Changes
    My problem is that when I go to into the BID (RFx) and click "Print Preview" it picks up the standard Smartform, not the new Adobe form I have added as required.
    Please can you advise of any additional config settings or other steps required to ensure that the Adobe Form is called when I click "Print Preview"?
    We are on SRM 7.0.
    I look forward your response.
    Regards,
    Matt

    Hi Matt could you please tell me how do you solve your issue? I have the same and I cant find the solution.
    Thanks a lot
    Kind Regards

  • Maintain session when calling servlet from form in a JSP

    I have the following set up:
    index.jsp calls login servlet from the action tag in a form.
    Login servlet handles the login, stores the user info and db connection in the session and uses forward(req,res) to call another jsp.
    That jsp has a form where user enters search info and in that form's action tag there is a search servlet. In the search servlet I am unable to access the session.
    Is there any way to pass the session to the servlet from that jsp using a form/action?

    I've read elsewhere that if you go from a jsp to a servlet that the >request object is cleared of any attributes from the previous request.which is correct. But arent we speaking about session object here? A request object is valid for a request - ie the phase from where the server receieves a hit for a resource upto the point it sends the output for that request.
    A session spans multiple requests.
    it doesn't retrieve the session info and gives me a null pointer >exception when I try to use the connection object stored in the session.Bad bad bad . Why do you store Connection objects in session? Create them when necessary or use a connection pool. Do you for example clean up the connections when the session expires. What if its a 30 minute session and the user hits every say 15 minutes with a request. Why do you need to hold on to the Connection in the intervening interval when the user's session is inactive?
    gives me a null pointer exception when I try to use the connection object stored in the session.which means that the Connection object is null - not the session object.
    That last line is where I get the null pointer exception. And that is
    Statement stmt = con.createStatement();?
    Same answer as above.
    If the session object was null,
    userSession.getAttribute("connection");would have thrown a NPE.
    ram.

  • Is the form action will be called automatically if there is no SUBMIT

    Hi there,
    i have a JSP with form action set to an Action class. the form dont have any submits.
    when i call the JSP the action class and and ActionForm are fetching the data displaying it on the same JSP(as i required).
    i am new to struts. even after my application working i have doubt, when i call the JSP how the action is getting called and Form populating the data with out any submit on the form
    Thanks
    R

    yes , you are right , my JSP has beans and forms and action class set up in
    strut-config.xml.you say that so the strut-config.xml parsed and on server side and without submit the action class will be called
    right?
    can you point me to any document(particular to this concept)please?

  • JSP/Servlet Feedback form confusion

    Hi,
    I hope someone can advise me. I have a jsp which collects feedback information from a form. I then want to call a java servlet to read this information, store it in a bean and send an email. At the moment when I click submit in the jsp form, the servlet isnt even being called.....Is it totally necessary for this kind of scenario that my servlet contain doget and dopost methods?
    Many thanks.(code below)
    //feedback jsp
    <form action=sendfeedbackemailcontrolservlet>
              <br><br>
               <div align="centre"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000066">
             <font face="Verdana, Arial, Helvetica, sans-serif" size="2">From:</font></font><font color="#000066"> 
                  <input type="text" name="fromemail" size="40">
                   <p align="left">  </p>
              Subject:
                 </font> <font color="#000066">  
                   <input type="text" name="subject" size="40">
                   <br><br><br>
                  <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Comments/Suggestions:
                   </font><br><br>
                   <textarea rows=6 cols=34 name="suggestions" ></textarea>
                   </font> </div>
                      <p align="left">  </p>
                  <div align="centre">
                    <input type="button" value="Submit Feedback" name="button">
                 <input type="reset" value="Clear all" name="reset">
                 </div>
         </form>
    //feedback servlet
    public class SendFeedbackEmailControlServlet extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html";
      //Initialize global variables
      public void init() throws ServletException {
      public static void send(HttpServletRequest request, HttpServletResponse response, String smtpHost, int smtpPort,String from, String to,String subject, String content)throws AddressException, MessagingException {
                 // Create a mail session
                 java.util.Properties props = new java.util.Properties();
                 props.put("mail.smtp.host", smtpHost);
                 props.put("mail.smtp.port", ""+smtpPort);
                 Session session = Session.getDefaultInstance(props, null);
                 // Construct the message
                 Message msg = new MimeMessage(session);
                 msg.setFrom(new InternetAddress(from));
                 msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
                 msg.setSubject(subject);
                 msg.setText(content);
                 // Send the message
                 Transport.send(msg);
                 RequestDispatcher rd = request.getRequestDispatcher("another.jsp");
                try {
                  rd.forward(request, response);
                catch (IOException ex) {
                catch (ServletException ex) {
    public static void main(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception {
        String fromemail = request.getParameter("fromemail");
        String subject = request.getParameter("subject");
        String suggestions = request.getParameter("suggestions");
        FeedbackBean bean = new FeedbackBean();
        bean.setSubject(subject);
        bean.setFromEmail(fromemail);
        bean.setSuggestions(suggestions);
        send(request, response, "smtp.host", smtp.port,bean.getFromEmail(), "[email protected]", bean.getSubject(), bean.getSuggestions());
      //Clean up resources
      public void destroy() {
    }

    Is it totally necessary for this kind of scenario that my servlet contain
    doget and dopost methods?Yes.
    Those are the methods that the server will call to invoke your servlet.
    Also your methods should not be static. It needs to create an instance of the servlet to invoke it.
    You could easily implement your doGet/doPost methods by just calling main(request, response) from them.

  • Form Actions

    Hi Everyone,
    Sorry about this post - I am a bit of a novice helping someone out with some problems they are having with a new website.
    I am not very familiar with the use of forms and actions, and I am trying to set up a page with a login section which will not be in use immediately. Therefore, just incase anyone tries to login, I want an error page to appear after they hit the login button.
    Can someone help me with how to do this please?
    Thanks a million for your help (in advance)
    Steph

    Typically, the form action is a url to a page with a server side script that processes the form contents. If you simply want an error page to display for now, just create the error page and use that (including the entire path) in the form action.

  • How to open a form action in a popup window?

    I have a form that has a submit button and a email button.  The email button calls a javascript fuction that will execute a mailform script.  everything is working fine, but I would like the output window from the mail formscript to open in a popup, but currently is opening in a blank page.
    currently hte output from the mail script will open in a _blank window.
    Thanks in advance for your help
    Here is the html code:
    <FORM name="drop_list" action="<?php echo $editFormAction; ?>"" method="POST" >
        <input name="emailForm" type="button" id="emailForm" onClick="sendFormEmail()" value="Email">
        <input name="add_patient" type="submit" id="add_patient" onclick=document.drop_list.action='<?php echo $editFormAction; ?>' value="Add Patient">
    Here is my javascript code:
    function sendFormEmail() //email form
                        document.drop_list.action = "html_form_send.php";
                        document.drop_list.target = "_blank";
      document.drop_list.submit();            // Submit the page
                        return true;
    and here is the html_form_send.php
    <?php
    if(isset($_POST['patient_email'])) {
        // CHANGE THE TWO LINES BELOW
              $email_to = '[email protected]';
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
    //    validation expected data exists
        if(!isset($_POST['patient_name']) ||
                     !isset($_POST['patient_email']) ||
                                  !isset($_POST['textBox']) ||
                     !isset($_POST['doc_comment']))
        //    died('We are sorry, but there appears to be a problem with the form you submitted.');      
        $first_name = $_POST['patient_name']; // required
        $email_from = $_POST['patient_email']; // required
              $comments = $_POST['doc_comment']; // required
        $error_message = "";
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Patient Email you entered does not appear to be valid.<br />';
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$first_name)) {
        $error_message .= 'The First Name you entered does not appear to be valid.<br />';
      if(strlen($comments) < 2) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      if(strlen($error_message) > 0) {
        died($error_message);
       function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
    // set subject line
        $email_subject = "referral form for " .$first_name ;
    // format message body
              $email_message = '<html><body>';
              $email_message .= '<table border="0">';
              $email_message .= "<tr ><td width='125' style='background: #eee;'><strong>Name:</strong> </td><td>" . strip_tags($_POST['patient_name']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Patient Phone:</strong> </td><td>" . strip_tags($_POST['patient_phone']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Side:</strong> </td><td>" . strip_tags($_POST['bodySideOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Area:</strong> </td><td>" . strip_tags($_POST['bodyPartOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Diagnosis:</strong> </td><td>" . strip_tags($_POST['subbodyPartOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Sub Cat:</strong> </td><td>" . strip_tags($_POST['subCatOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Injury2</strong> </td><td></td></tr>";
              $email_message .= "<tr><td><strong>Side2:</strong> </td><td>" . strip_tags($_POST['I2bodySideOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Area2:</strong> </td><td>" . strip_tags($_POST['I2bodyPartOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Diagnosis2:</strong> </td><td>" . strip_tags($_POST['I2subbodyPartOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Sub Cat2:</strong> </td><td>" . strip_tags($_POST['I2subCatOutput']) . "</td></tr>";
              $email_message .= "<tr><td><strong>Doctor Comment:</strong> </td><td width='125' style='background: #eee;'>" . strip_tags($_POST['doc_comment']) . "</td></tr>";
              $email_message .= "</table>";
       $email_message .= "</body></html>";
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: '. $email_to."\r\n";
    //$headers .= 'CC: '. $email_to. "\r\n";
    //$headers .= 'From: '. $email_from. "\r\n";
    //$headers .= 'CC: '. $email_from. ',' . $email_to."\r\n";
    //send mail
    mail($email_from, $email_subject, $email_message, $headers);
    //mail($email_from, $email_subject, $email_message, $headers);
    ?>
    <!-- place your own success html below -->
    Email Sent
    <?php
    die();
    ?>

    Im currently trying to take all the validation out of the mail script and do it in the html page itself. 
    Bad choice.   Client-side form validation isn't secure  and it does not work if JavaScript is disabled.  A fair number of people turn off JavaScript or use one of the No-Scripts Add-ons in their browsers for perceived security reasons.
    Don't forget, spam bots don't use JavaScript either so they will penetrate your forms without missing a beat. 
    Server-side validation is very reliable.  And if your script is built properly, it can stop robot submissions and exploitation of your forms which is very important these days.
    Nancy O.

  • Problem with a primary key when creating a new record in Forms

    My table has a field - MDD_KEY - that is a primary key. It is updated from a sequence with a before-insert database trigger. I know this works properly as the primary key was accurately populated when I inserted 1433 records.
    In Forms 6, I have a form based on that table. I have set the mdd_key as a hidden field because I assume it will be entered by the before-insert trigger. However, when I enter data into the table, and then try to save it, I get a FRM-40202: Field must be entered. - followed by - FRM-40222: Disabled item MDD_KEY failed validation.
    If I set DATA Required to no, when I try to save I get an FRM-40600: Record has already been inserted - but no such record exists in the database. I know this record is unique and does NOT exist because I deliberately made it up.
    In the property palatte, the attributes of the field are:
    DATA Data Type Number
    Required Yes
    DATABASE Database Item Yes
    Primary Key Yes
    Query Only No
    Query Allowed Yes
    Query Length 0
    Insert Allowed Yes
    Update Allowed Yes
    Update Only if Null No
    Lock Record No
    I assume that my problem is that with a new record, the form wants to see the MDD_KEY populated before it saves - but that isn't going to happen until the before insert trigger fires in the database. I assume I have to populate that field within forms, but how do I do that without messing up the database trigger/sequence? I will have to load more data directly into the database - so I need the database trigger in place.
    I have not used primary keys before so I am more than a little bit confused about how and when it should be populated when a new record is created in Forms.
    Any help would be appreciated as I cannot enter new data into my form (works well with existing data).
    Thanks
    Glenn

    hi
    if u have any problem using seq then try that statemetn ur block level in ur form
    PRE-INSERT trigger
    select nvl(max(nvl(srno,0)),0)+1 into :srno from tablename;
    Rizwan

  • New to Adobe Forms and need help with Submit Email button

    I am new to Adobe Forms in Windows.  I created a form with a submit email button.  When users try to click the button, the message is operation cannot be completed.  My test user has Adobe Reader 9 installed.  I'm at a loss as to how to resolve the issue.  Please assist.  TIA!

    Three different aspects
    1. Set the form up to submit the data (XML or FDF), not the full PDF. You can import the data to the PDF on your end.
    2. You can turn on Extended Reader Rights, but then limit the use/users to 500 by the EULA. The applicability of this option depends on your intended application. In a small office, it would be fine. For general web use you would likely exceed the limit and be in violation of the EULA.
    3. There may be an e-mail problem, one reason that e-mail is not recommended for form submission (even if the manual discusses it). Again, in a controlled environment like an office it will probably work fine, but in a web setup it is best to use a web script. There are 2 problems with e-mail that both depend on the client system (YOU have no control, but will be blamed in any case). First, the client machine has to be set up as an active MAPI client. Many folks do not have this on. Second, some e-mail clients treat PDFs like text and the result is a corrupt e-mail submission, even if it makes to you.
    If you have the possibility of web submission, do it. I suggest only having the form data submitted and not the form.

  • How to set authenticationQuestion from a async form

    Hi,
    I need to set the authenticationQuestion and answers for new users coming
    from a db table.
    Do you have an idea of the data structure to use?
    Thanks a lot in advance.

    You need to check out the ChangeUserAnswers:
    <Action name='Checkout Set Answers User View' application='com.waveset.session.WorkflowServices'>
    <Argument name='id' value='$(accountId)'/>
    <Argument name='op' value='checkoutView'/>
    <Argument name='type' value='ChangeUserAnswers'/>
    <Return from='view' to='theSetAnswersView'/>
    </Action>
    And then you can set the answers:
    <set name='theSetAnswersView.waveset.questions[#0].answer'>
    <ref>global.firstname</ref>
    </set>
    To save the view - checkin:
    <Action name='Checkin Set Answers User View' application='com.waveset.session.WorkflowServices'>
    <Argument name='view' value='$(theSetAnswersView)'/>
    <Argument name='op' value='checkinView'/>
    </Action>

  • How to send query string by using form action

    Hai to all,
    I am new to this topic Ihave one doubt about jsp form action....
    That is I am using input type is submit button
    <input type="submit" name="submit" value="Edit" onclick="indows.location.href=+sample.jsp?query=+editvalue+editname">
    If I get that queryString in the sample.jsp page it respoce to the null only...... what is the problem to this code ..... please send ur perfect coding as soon as possible. I really waiting for ur replay..........

    Hai,
    I think u can use the "request.getQueryString()" to get the query string instead of using "request.getParameter()".
    From the query string value u can get the output.
    cheers,
    Redrose

Maybe you are looking for

  • Help installing mac os x tiger

    so i installed disc one of mac os x tiger on my macbook, and when it asks for disc two and i insert it, it loads all the way, then when my computer is turning on it goes back to the beginning of the install and keeps repeating the process. please hel

  • How to display ?

    This is program, TYPES : BEGIN OF TY_HEAD,          TICK_NO TYPE ZTICK_NO,          FISRT_WT TYPE ZFT_WEIGHT,          F_DATE TYPE ZDATE,          SECOND_WT TYPE ZSC_WEIGHT,          SEC_DATE TYPE ZDATE,          NET_WEIGHT TYPE ZNET_WT,         END

  • When I "Convert Selection For iPod" the converted file has no audio.HELP!!!

    I have tried many times but the converted file always ends up with no audio. The files I am trying to convert are just basic Windows Media Player video/movie files each under 1GB.

  • Viewing MS Explorer dependent website

    I've come across several webpages that "don't work" with Safari or Firefox for mac, yet they work perfectly fine on a PC with Explorer. Now that Explorer is unavailbe for macs, does anyone have any suggestions on how to view this material on a mac?

  • Add custom fields VL10G

    Hi all, I want to add some custome fields to be seen in alv output for tcode VL10G . I had a look at V50R_USEREXITS. What things i need to output are not in SHP_VL10_ITEM. Please advise. Regards, Himanshu