Forwarding requests on to non-java pages from servlet.

I have designed a web application using a form of single controller pattern.
I have a number of JSPs.
Each of these JSP's has a form element which if submitted got to a single servlet (Controller)which then forwards on the request to a different class based on the paramter passed. For example this form would call the SubmitFeedback class.
<form name="feedbackform" method="post" action="<%=request.getContextPath()%>/controller">
<input type="hidden" name="action" value="SubmitFeedback"/>
<input type="hidden" name="page"   value="feedback.jsp">
<tr><td><input type="submit" name="go" value="Go"/></td></tr>
</table>
</form>After the class has done its processing it returns what page to go next to the Controller class and this forwards the request on. to the next jsp
String nextPage = createAction(request.getParameter(PARAM_ACTION)).handleRequest(this,request, response, request.getParameter(PARAM_PAGE));          
request.getRequestDispatcher(nextPage).forward(request, response);
return;This is all fine but now I have a sitation where after the user submits the form I want do some processing then forward them onto another page which is not part of my system, nor java. But the RequestDispatcher is only for the current Context within a Servlet Container.
Could someone explain how I do this, what am Im missing please.

i am not a JavaScript expert, so I can't be sure this is everything, but:
1) The javascript has to be put inside a <script></script> block (you also had an extra close bracket):
<script type="text/javascript">
  <!--
  function validateAccept() {
    toReturn=true;
    if (form.accept.checked==false) {
      alert("You must select at least one checkbox to search");
      toReturn=false;
    return toReturn;
  //-->
</script>The script block is usually put in the head section also, but that is not necessary.
2) I would call this function from the onsubit event of the form rather than the onclick of the submit button
<form  name="form" action="..." method="post" onsubmit="return validateAccept();">
  //...3) You will need to identify the form that you want to use inside the function. Just using the name form won't work, it has to be retrieved from a certain context. The easiest thing is to pass it in as a parameter:
<script type="text/javascript">
  <!--
  function validateAccept(form) {
<form  name="form" action="..." method="post" onsubmit="return validateAccept(this);">

Similar Messages

  • How to send a http request to a non java appln

    I have one legacy web application running which can handle only http request . So I need to connect (using http request) and send my request and get the response, without opening that application in browser.
    Any idea
    1) How to connect to non - java appln from a java appln ?
    2) How to use the Httprequest without displaying the page using browser?

    You can try one of three routes:
    Open a socket and write the HTTP request and parse the HTTP response yourself
    Use java.net.URLConnection
    Use Jakarta Common's HttpClient at jakarta.apache.org- Saish

  • How do you extract non consecutive pages from a pdf document. I can highlight in thumbnails but only extract consecutive.

    How do you extract non consecutive pages from a pdf document?
    I see its easy to do it with consecutive pages by highlighting thumbnails then 'extract' but this does not allow for non consecutive pages.
    Thank you

    After highlighting the pages you can drag them and drop them somewhere,
    like on the desktop, and a new file will be created with just those pages.
    If highlighting the pages is not feasible, or too tricky to do, then a
    script can be used where you specify which pages to extract and the script
    extract them to a new file.

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • Access SSL pages from servlet

    Hi,
    I request your assistance with the following please:
    I have a web application running on tomcat4.1 with mySql, for enrolment.
    It consists of pages :
    1- Welcome page
    2- Personal details part 1
    3 - Personal details part 2
    4 - Authorize to save to database
    Page 1 goes to a servlet that sets beans etc..
    I need to then proceed to page 2->3->4 with an SSL protocol. I have purchased a certificate and the hosting company has confirmed that it is installed.
    I would welcome some direction on how to modify the code from the following :
    theURL="page2.jsp";
    RequestDispatcher dispatcher=request.getRequestDispatcher(theURL);
    dispatcher.forward(request, response);
    to get to page 2 within an SSL layer.
    Your advice will be greatly appreciated.
    Thank you.

    Found the solution.
    In the doGet method add:
    SessionBean1 sessionBean1 = (SessionBean1) req.getSession().getAttribute("SessionBean1");       

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • Runing java pogram from Servlet

    Hi everbody
    I was trying to execute and run a java program from servlet. It seems to me the servlet can compile the code but it is not capable to execute it. I have tried to save the class file in a bat file after the servlet compiled it but it did not work. any help will be appreciated.
    try{
    String[] command = {"javac","c:\\class\\test.java"};
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(command);
    catch(Exception ex){ }
    try{
    String[] command = {"java","c:\\class\\test"};
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(command);
    catch(Exception ex){ }

    Don't cross-post your questions, please.

  • Passing Request Parameters to Non JSF Page

    I want to pass request parameters from a JSF page (Page1.jsp) to a non JSF page (paramTest.jsp) and am having trouble.
    The parameters are 'null' in the non JSF page.
    Here is code (in Page1.java) that is called when 'button1' is clicked in Page1.jsp (modified from JSF, Bergsten p.167):
    public String button1_action() {
            FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
            ExternalContext ec = context.getExternalContext();
            try {
                ec.redirect("http://xxx/paramTest.jsp");
            } catch (Exception e) {
                // print exception information in the server log
                log("Exception occurred when redirecting page", e);
                error("Trouble redirecting page");
                return null;
            context.responseComplete();
            return "success";
        }Here is Page1.jsp code: <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page1 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page1.form1}" id="form1">
                        <h:inputText binding="#{Page1.name}" id="name" style="left: 144px; top: 96px; position: absolute"/>
                        <h:outputLabel binding="#{Page1.componentLabel1}" for="componentLabel1" id="componentLabel1" style="left: 72px; top: 96px; position: absolute">
                            <h:outputText binding="#{Page1.componentLabel1Text}" id="componentLabel1Text" value="Name:"/>
                        </h:outputLabel>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" onclick="this.form.submit() style="left: 120px; top: 144px; position: absolute" value="Submit"/>
                        <h:messages binding="#{Page1.messageList1}" errorClass="errorMessage" fatalClass="fatalMessage" id="messageList1" infoClass="infoMessage"
                            showDetail="true" style="left: 480px; top: 72px; position: absolute" warnClass="warnMessage"/>
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>Here is the rendered Page1.jsp html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xml:lang="en-US" lang="en-US">
    <head>
    <meta http-equiv="Cache-Control" content="no-cache"/><meta http-equiv="Pragma" content="no-cache"/>
    <title>Page1 Title</title>
    <link type="text/css" rel="stylesheet" href="resources/stylesheet.css"/>
    </head>
    <body style="-rave-layout: grid">
    <form id="form1" method="post" action="/cenwkd/faces/Page1.jsp;jsessionid=79A5577F53DAAEDF164C5D33F33D8327" enctype="application/x-www-form-urlencoded">
    <input id="form1:name" type="text" name="form1:name" style="left: 120px; top: 96px; position: absolute" />
    <label id="form1:componentLabel1" for="form1:componentLabel1" style="left: 72px; top: 96px; position: absolute">
    <span id="form1:componentLabel1Text">Name:</span></label>
    <input id="form1:button1" type="submit" name="form1:button1" value="Submit" onclick="" style="left: 120px; top: 144px; position: absolute" />
    <input type="hidden" name="form1" value="form1" />
    </form>
    </body>
    </html> Here is the source for a test jsp, paramTest.jsp: <html>
    <head>
    <title>
    paramTest
    </title>
    </head>
    <body>
    <h2><%= request.getParameter("form1:name")%></h2>
    <%-- Also tried: request.getParameter("name"), "name" is the original 'id' value for the text field entered in Creator
         it apparently is changed to "form1:name" when the html is rendered--%>
    </body>
    </html>Here is the rendered html from paramTest.jsp: <html>
    <head>
    <title>
    paramTest
    </title>
    </head>
    <body>
    <h2>null</h2>
    </body>
    </html>Any help would be much appreciated.

    Hi,
    I dont see any parameters that you are trying to pass in the below code.
    public String button1_action() {
    FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
    ExternalContext ec = context.getExternalContext();
    try {
    ec.redirect("http://xxx/paramTest.jsp");
    } catch (Exception e) {
    // print exception information in the server log
    log("Exception occurred when redirecting page", e);
    error("Trouble redirecting page");
    return null;
    context.responseComplete();
    return "success";
    }

  • Calling third party java page from self sevice page

    Hi,
    Is it possible to call a third party java (html+java) form page (residing in separate web service server) which would take input from standard Oracle apps (OCO) self service OAF page?
    The third party page would validate the fields sent by OAF page and then will provide the results which should be copied back into standard oracle OCO page (self service OAF page)
    From How to open HTML page from OAF it looks like this is possible.
    Can you please confirm ?
    Regards,
    Aneesh

    Technically it will depend more on the third party system involved in the discussion and the way it is integrated. But in the simplest terms, url parameters will always work.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                               

  • Can display Web pages from servlet but not applet?

    I have been able to display real-world Web pages from a simple servlet using JDeveloper 3.0, but can't figure out how to do the same from an applet. Any hints?

    My previous post had the detail...Probably a simple question from a relative novice. I'm having a problem just viewing web pages by calling them from a "list" of URLs in an applet. I built an applet with a split pane that has a JTree on one side and an "HTML viewing pane" on the other. I can click JTree nodes to display local html files, but I don't understand how to display web pages from the Internet. Do I need something like HyperlinkListener to make the jump to "hyper-world"???

  • Calling Java application from servlet

    Hi !
    I'm trying to run a Java application from within a servlet with Tomcat 4. I'm using the Runtime.getRuntime ().exec () method. So the application is run in a different JVM as a subprocess of the servlet. I use ObjectInputStream and ObjectOutputStream and a serializable object to enable communication between the servlet and the application.
    I tested the application and the serializable object with another Java application that works as the caller and it works fine. However, replacing the caller application with the servlet I get a StreamCorruptedException. The structure of the caller application and the servlet is the same.
    My questions are:
    - Is there something I should configure in Tomcat to create a subprocess ?
    - What is the cause of the StreamCorruptedException ? How do I get it with the servlet and not with the application ?
    - Should I use an environment with the call to Runtime.getRuntime ().exec () ? How do I use it ?
    - Is the called application forced to run in my servlet's context ?
    - Is there a better way to do this ?
    Thanks to all

    Here's my code:
    1. The serializable object:
    // Object Obj
    import java.io.*;
    public class Obj implements Serializable
    public int n;
    public Obj ()
    n = 0;
    public Obj (int n)
    this.n = n;
    public String toString ()
    return getClass ().getName () + " -> (n = " + n + ")";
    2. The application Sub (subprogram)
    // Application Sub
    import java.io.*;
    public class Sub
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, InterruptedException, ClassNotFoundException
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj;
    ois = new ObjectInputStream (System.in);
    obj = (Obj) ois.readObject ();
    f = new File ("Sub.txt");
    fw = new FileWriter (f);
    fw.write (obj.toString ());
    fw.close ();
    oos = new ObjectOutputStream (System.out);
    oos.writeObject (obj);
    ois.close ();
    oos.close ();
    3. The application AMain (caller application)
    // Application AMain
    import java.io.*;
    class AMain
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, ClassNotFoundException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    r = Runtime.getRuntime ();
    p = r.exec ("java Sub");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    B.comunica (obj);
    System.out.println ("AMain sends to Sub: " + obj.toString ());
    try
    p.waitFor ();
    catch (InterruptedException e)
    System.out.println ("Subprogram was interrupted");
    System.out.println (e.toString ());
    ois = new ObjectInputStream (p.getInputStream ());
    System.out.print ("Sub sends to AMain: ");
    obj2 = (Obj) ois.readObject ();
    System.out.println (" " + obj2.toString ());
    oos.close ();
    ois.close ();
    p.destroy ();
    4. The servlet SMain (the calling servlet)
    // Servlet SMain
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class SMain extends HttpServlet
    public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    int state, i;
    res.setContentType ("text/html");
    ServletOutputStream out = res.getOutputStream ();
    out.println ("<html>");
    out.println ("<head><title>Sub</title></head>");
    out.println ("<body>");
    out.println ("Invoking subprogram...");
    out.println ("<br>");
    try
    r = Runtime.getRuntime();
    p = r.exec ("java -cp .;c:\\Programs\\Apache~1.0\\webapps\\SMain\\WEB-INF\\classes Sub");
    out.println ("...invoked<br>");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    out.println ("<br>SMain sends to Sub: " + obj.toString () + "<br>");
    try
    p.waitFor ();
    catch (InterruptedException e)
    out.println ("<br>Subprogram was interrupted<br>");
    out.println ("<br>" + e.toString () + "<br>");
    state = p.exitValue ();
    out.println ("<br>Subprogram state: " + state + "<br>");
    ois = new ObjectInputStream (p.getInputStream ());
    out.print ("<br>Sub sends to SMain: ");
    obj2 = (Obj) ois.readObject ();
    p.destroy ();
    catch (SecurityException e)
    out.println ("<br>SecurityException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (IOException e)
    out.println ("<br>IOException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (Exception e)
    out.println ("<br>Exception<br>");
    out.println ("<br>" + e.toString () + "<br>");
    out.println ("</body>");
    out.println ("</html>");
    So, as you can see, both application AMain and servlet SMain invoke application Sub and pass it the serializable object Obj. Oddly enough, application AMain works fine whereas servlet SMain throws a StreamCorruptedException exception.
    johnpoole said:
    �It's hard to guess what would cause the exception without seeing code, but the interaction between the processes would differ from that between two applications, because the servlet process is started with a different class loader. I'm not sure which one the jvm started by the call would use.�
    How can I enforce that a System classloader be used in the call to Runtime.getRuntime ().exec () ? (I mean by System classloader a classloader equals to the one applications are launched from console).
    johnpoole said
    �Is there a reason why you aren't starting the second process manually and then connecting to it on a port?�
    The idea is providing a Web interface for an application running in the server. The servlet is used to restrict access to this application but once access is granted (passing the servlet) the application should not be constrained.

  • Need to Call OA Page from Servlet

    Hi All,
    My requirement is to call OAF page from the servlet.
    Can anyone please give me some pointers to achieve this.
    Thanks
    Anoop

    hi
    anoop ,check if this thread can help u
    how to call a OA page from a jsp page
    thanx
    Pratap

  • Calling third party java page from Oracle form

    Hi,
    Is it possible to call a third party java (html+java) form page (residing in separate web service server) which would take input from standard Oracle form (OCO) page?
    The third party page would validate the fields sent by form page and then will provide the results which should be copied back into standard oracle OCO form page.
    Regards,
    Aneesh

    Don't know if you can do this from Forms PL/SQL, but you should be able to write a stored procedure in the database that does it for you. The stored procedure could use the database package UTL_HTTP to make the HTTP request and receive the response.
    Your custom stored procedure can be called from Forms PL/SQL. If you are caling to a tru web service, you can also look at the UTL_DBWS package which is a bit more high level for calling a web service, than the raw UTL_HTTP package.

  • Error Occured while processing a Request-openning a another coldfusion page from old page link

    in one page there is dynamic link in that i want to open anather page...
    code is compiled ok and page is at place where i refered a link but it gives error 'error occured while processing a request'
    Error Diagnostic Information
    An error has occurred.
    HTTP/1.0 404 Object Not Found
    this error shows please help me...
    i am new in coldfusion.
    Thanks.

    Hi Salvatore,
    This is a very wide error. You did not provided any other info as specified by Michael. Just a wild guess, this sort of error occurs generally when classpath or java_home properties are not set correctly. But, as i said it is very wide, some more info will be useful.
    Regards
    Chander Kararia

  • Communicating w. running (non-Java) process from Java

    I'd like to be able write a Java program that can run an instance of a text editor, say NotePad or TextPad, with some text file open (I know how to do this via the Runtime class' exec method), but then, at a later point, open some other text file in that same running instance of the text editor. This is on Windows XP btw... with Java 1.4.x
    Can this be done? Specifically can it be done in the case of NotePad or TextPad?
    If this can be done, and someone can give me some pointers on how it's done, I'd greatly appreciate it... Thanks in advance.

    You will have to make use of native methods for that. Or use something with Runtime.exec();

Maybe you are looking for