Sending Javascript call in servlet response.

I am calling a servlet from a javascript ( .js) file. Based on the status of the server I want send javascript function call to the client browser.
Is it possible?
Here is what I am trying to do :
response.sendRedirect("javascript:myfinction()");
myfunction() is defined in the source .js file from where I am calling the servlet.
Hope you understand what I am trying to do. Please help.
Thanks
Pradip

That won't be possible as the servlet executes first on the server, then javascript executes on the client.
Remember that Javascript requires the browser to do anything, it's the browser functionality that it runs in. The servlet executes on the server, then forwards to the client, and therefore has no access to javascript whatsoever, at least not in the context that you're speaking of. By the time javascript is ready to start, the servlet has already completed.
If it was the other way around, that would be possible (i.e. use JSP/Servlet to set javascript variable value).
Sorry.

Similar Messages

  • I want to send a response from the servlet and then call another servlet.

    Hi,
    I want to send a response from the servlet and then call another servlet. can this happen. Here is my scenario.
    1. Capture all the information from a form including an Email address and submit it to a servlet.
    2. Now send a message to the browser that the request will be processed and mailed.
    3. Now execute the request and give a mail to the mentioned Email.
    Can this be done in any way even by calling another servlet from within a servlet or any other way.
    Can any one Please help me out.
    Thanks,
    Ramesh

    Maybe that will help you (This is registration sample):
    1.You have Registration.html;
    2.You have Registration servlet;
    3.You have CheckUser servlet;
    4.And last you have Dispatcher between all.
    See the code:
    Registration.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
      <HEAD>
        <TITLE>Hello registration</TITLE>
      </HEAD>
      <BODY>
      <H1>Entry</H1>
    <FORM ACTION="helloservlet" METHOD="POST">
    <LEFT>
    User: <INPUT TYPE="TEXT" NAME="login" SIZE=10><BR>
    Password: <INPUT TYPE="PASSWORD" NAME="password" SIZE=10><BR>
    <P>
    <TABLE CELLSPACING=1>
    <TR>
    <TH><SMALL>
    <INPUT TYPE="SUBMIT" NAME="logon" VALUE="Entry">
    </SMALL>
    <TH><SMALL>
    <INPUT TYPE="SUBMIT" NAME="registration" VALUE="Registration">
    </SMALL>
    </TABLE>
    </LEFT>
    </FORM>
    <BR>
      </BODY>
    </HTML>
    Dispatcher.java
    package mybeans;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Dispatcher extends HttpServlet {
        protected void forward(String address, HttpServletRequest request,
                               HttpServletResponse response)
                               throws ServletException, IOException {
                                   RequestDispatcher dispatcher = getServletContext().
                                   getRequestDispatcher(address);
                                   dispatcher.forward(request, response);
    Registration.java
    package mybeans;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Registration extends Dispatcher {
        public String getServletInfo() {
            return "Registration servlet";
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            ServletContext ctx = getServletContext();
            if(request.getParameter("logon") != null) {          
                this.forward("/CheckUser", request, response);
            else if (request.getParameter("registration") != null)  {         
                this.forward("/registration.html", request, response);
    CheckUser.java
    package mybeans;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class CheckUser extends Dispatcher {
        Connection conn;
        Statement stat;
        ResultSet rs;
          String cur_UserName;
        public static String cur_UserSurname;;
        String cur_UserOtchestvo;
        public String getServletInfo() {
            return "Registration servlet";
        public void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            try{
                ServletContext ctx = getServletContext();
                Class.forName("oracle.jdbc.driver.OracleDriver");
                conn = DriverManager.getConnection("jdbc:oracle:oci:@eugenz","SYSTEM", "manager");
                stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
               String queryDB = "SELECT ID, Login, Password FROM TLogon WHERE Login = ? AND Password = ?";
                PreparedStatement ps = conn.prepareStatement(queryDB); 
               User user = new User();
            user.setLogin(request.getParameter("login"));
            String cur_Login = user.getLogin();
            ps.setString(1, cur_Login);
            user.setPassword(request.getParameter("password"));
            String cur_Password = user.getPassword();
            ps.setString(2, cur_Password);
         Password = admin");
            rs = ps.executeQuery();
                 String sn = "Zatoka";
            String n = "Eugen";
            String queryPeople = "SELECT ID, Surname FROM People WHERE ID = ?";
           PreparedStatement psPeople = conn.prepareStatement(queryPeople);
                      if(rs.next()) {
                int logonID = rs.getInt("ID");
                psPeople.setInt(1, logonID);
                rs = psPeople.executeQuery();
                rs.next();
                       user.setSurname(rs.getString("Surname"));
              FROM TLogon, People WHERE TLogon.ID = People.ID";
                       ctx.setAttribute("user", user);
                this.forward("/successLogin.jsp", request, response);
            this.forward("/registration.html", request, response);
            catch(Exception exception) {
    }CheckUser.java maybe incorrect, but it's not serious, because see the principe (conception).
    Main is Dispatcher.java. This class is dispatcher between all servlets.

  • Xhtml call to servlet not returning response, not calling servlet

    I have xhtml in a web app making a call to a servlet but the response from the servlet is not displaying. The original xhtml displays after the submit button is pressed. I tried different alternatives for the servlet response, but I get the same result each time. I added logging to the servlet, but it looks like the servlet is not being called at all.
    xhtml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:ejstreegrid="https://unfccc.int/nais/ejstreegrid"
    xmlns:grid="http://java.sun.com/jsf/composite/gridcomp"
    xmlns:nais="http://java.sun.com/jsf/composite/naiscomp">
    <body>
    <ui:composition template="/templateForm.xhtml">
    <ui:define name="title">Some title</ui:define>
    <ui:param name="currentPage" value="somepage.xhtml" />
    <ui:define name="body">
    name to be added<br/><br/>
    <form action="someServlet" method="post">
    <input type="text" name="someName" />
    <input type="submit" />
    </form>
    </ui:define>
    </ui:composition>
    </body>
    </html>servlet in web app being called:
    package netgui.servlet;
    import java.io.IOException;
    import java.util.Enumeration;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class someServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public someServlet() {
    super();
    protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException   {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    processRequest(request, response);
    private void processRequest(HttpServletRequest request,
    HttpServletResponse response) throws IOException {
    try {
    response.getWriter().write("some response");
    } catch (Exception e) {
    logger.error(e.getMessage());
    e.printStackTrace();
    response.getWriter().println("Error: " + e.getMessage());
    I also have a menu.xhtml that is calling the xhtml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <body>
    <script type="text/javascript">
    $(document).ready(function() {
    $("#btn").click(function() {
    $("#upload").click();
    return false;
    </script>  
    <ui:composition>
    <div id="navigation_bar">
    <ul id="topbarleft">
    <c:choose>                 
    <c:when test="${currentPage=='somepage.xhtml'}">
    <li><b>Some Page display</b></li>
    </c:when>
    <c:otherwise>
    <li><h:outputLink value="somepage.jsf">
    <h:outputText value="some page" />
    </h:outputLink></li>
    </c:otherwise>
    </c:choose>
    </ul>
    </div>
    </ui:composition>
    </body>
    </html>Is there some special format for submitting a form to a servlet from xhtml? Any ideas what could be wrong?
    Edited by: Atlas77 on Apr 16, 2012 6:53 AM
    Edited by: Atlas77 on Apr 16, 2012 6:54 AM
    Edited by: Atlas77 on Apr 16, 2012 6:56 AM
    Edited by: Atlas77 on Apr 16, 2012 7:27 AM

    You have a template. That template doesn't have for example a h:form of its own in which the body content is placed right? Nested forms don't work.
    Also for the next time, use \ tags to post code; that makes it actually readable. As you can see, the forum is now trying to interpret some special characters for formatting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Javascript calls from flash send GET request

    I'm having this problem with calling a javascript function
    after opening a new URL from flash. Basically what I have going on
    in my flash is a button, that when clicked, opens a new URL in
    "_blank" sending values to it using a POST request (I have done
    this both by using getURL and by using a LoadVars object). This
    part works fine, however immediately after it, I have a call to the
    javascript function "window.close()" (which I have done both using
    getURL and ExternalInterface). This works great in Firefox, but in
    IE the POST request seems to be getting interrupted by the
    javascript call.
    I did a check on the values getting passed using Charles, and
    it clearly shows that in IE there is a POST request getting sent to
    the page I'm loading in the new window, immediately followed by a
    GET request. This get request overrides the POST and for some
    reason only appears when making a javascript called. If I change
    that javascript call to opening a new URL in _self, for example, it
    doesn't show up.
    Does anyone have any idea what this is all about? Is there a
    solution to this? Why is this happening?!

    Thanks for the speedy reply!
    I'll just have to double check to make sure that any of the AJAX calls are security checked.

  • Delaying server [servlet] response

    I'm using AJAX to update my div tag telling me if a username is valid / invalid. I've tried using wait(long) to pause the doGet thread , init thread and start thread but I get the following warning:
    "Current thread not owner"
    Who's the owner or "main" thread? I've also tried respone.wait and request.wait but the same exception is being thrown. Or is there a different way to delay the servlets response, or is this impossible with XML?
    Thanks,
    -ls6v

    it sort of sounds to me like you're used to thick
    client gui programming - not sure why - but trying to
    control the number of hits to a database in a web
    app
    by messing with javascript controls smells a bit (it
    may be because of the nature of AJAX which I admit I
    haven't used). Embedding in depth knowledge of the
    back end in the front end is always a bit odd.
    Would it not be better to implement this sort of
    control (as in programmatic logic) server side ? Is
    there a need for an AJAX request to hit a database
    each time ? Might create an awful load (maybe this is
    what you're addressing). Perhaps some cached server
    side data structure might be of better use than
    trying to hack the front end in this fashion.Basically I'm going to use AJAX for the its look and feel, even if it isn't necessary. The load was what the other person brought up so I thought I could test it by slowing things down because I can't simulate 1,000 simultaneous connections. I'm not really worried about it because I figured that AJAX might actually help an over loaded server. If the server is too busy to respond I would catch that in my JS and and try to request it again after a few seconds. req.open("GET", url2, true);
    req.onreadystatechange = callback;
    req.send(null);
    function callback()
    if (req.readyState == 4)
            if (req.status == 200)
    else if(){...}
    }So if it comes back busy it'll wait before requesting the server again. I'll use DOM to manipulate the original login.html page so the input field will call a different JS function if it fails the first time. There's a bit more but that's what I'm going to try to do and hopefully bypassing this slow down testing won't matter.

  • Concurrent processing of POST requests and automatic flushing of the servlet response buffer in WLS6.1.

              Hi all,
              I encountered the following 2 servlet problems in WLS 6.0/ 6.1:
              1. Processing concurrent POST requests
              WLS seems to disallow concurrent executions of any servlet's doPost servlet method.
              When two clients attempt to send a request to a servlet using POST, the socond
              one
              is blocked until the first customer is served. In essence, the servlet ends up
              operating in
              1-user mode. I just learned from Jervis Liu that the problem is solved in WLS6.0
              if you disable http-keepalive.
              For WLS 6.1 a partial workaround is to make the servlet work in a single-thread
              mode (by implementing the javax.servlet.SingleThreadModel interface). In this
              case,
              WLS dispatches concurrent requests to different instances of the servlet.
              This doesn't completely eliminate the problem - still only one customer can be
              connected at a time. The improvement is that once the first customer is disconnects,
              the second can be served even if the doPost method for the first has not finished
              yet.
              2. Flushing the response buffer in WLS 6.1
              The servlet response buffer is not flushed automatically until doPost ends, unless
              you
              explicitly call response.flushBuffer(). Closing the output stream doesn't flush
              the
              buffer as per the documentation.
              I see that other people are experiencing the same problems.
              Has anyone found any solutions/workarounds or at least an explanation.
              Any input would be highly appreciated.
              Thanks in advance.
              Samuel Kounev
              

    Thanks for replying. Here my answers:
              > Did you mark your doPost as synchronized?
              No.
              > Also, try testing w/ native i/o vs not ... is there a difference?
              With native I/O turned off I get a little lower performance, but the
              difference is not too big.
              Best,
              Samuel Kounev
              > Peace,
              >
              > --
              > Cameron Purdy
              > Tangosol Inc.
              > << Tangosol Server: How Weblogic applications are customized >>
              > << Download now from http://www.tangosol.com/download.jsp >>
              >
              > "Samuel Kounev" <[email protected]> wrote in message
              > news:[email protected]...
              > >
              > > Hi all,
              > >
              > > I encountered the following 2 servlet problems in WLS 6.0/ 6.1:
              > >
              > > 1. Processing concurrent POST requests
              > >
              > > WLS seems to disallow concurrent executions of any servlet's doPost
              > servlet method.
              > >
              > > When two clients attempt to send a request to a servlet using POST, the
              > socond
              > > one
              > > is blocked until the first customer is served. In essence, the servlet
              > ends up
              > > operating in
              > > 1-user mode. I just learned from Jervis Liu that the problem is solved in
              > WLS6.0
              > >
              > > if you disable http-keepalive.
              > >
              > > For WLS 6.1 a partial workaround is to make the servlet work in a
              > single-thread
              > >
              > > mode (by implementing the javax.servlet.SingleThreadModel interface). In
              > this
              > > case,
              > > WLS dispatches concurrent requests to different instances of the servlet.
              > > This doesn't completely eliminate the problem - still only one customer
              > can be
              > >
              > > connected at a time. The improvement is that once the first customer is
              > disconnects,
              > > the second can be served even if the doPost method for the first has not
              > finished
              > > yet.
              > >
              > > 2. Flushing the response buffer in WLS 6.1
              > > The servlet response buffer is not flushed automatically until doPost
              > ends, unless
              > > you
              > > explicitly call response.flushBuffer(). Closing the output stream doesn't
              > flush
              > > the
              > > buffer as per the documentation.
              > >
              > > I see that other people are experiencing the same problems.
              > >
              > > Has anyone found any solutions/workarounds or at least an explanation.
              > > Any input would be highly appreciated.
              > >
              > > Thanks in advance.
              > >
              > > Samuel Kounev
              =====================================================
              Samuel D. Kounev
              Darmstadt University of Technology
              Department of Computer Science
              DVS1 - Databases & Distributed Systems Group
              Tel: +49 (6151) 16-6231
              Fax: +49 (6151) 16-6229
              E-mail: mailto:[email protected]
              http://www.dvs1.informatik.tu-darmstadt.de
              http://skounev.cjb.net
              =====================================================
              [att1.html]
              

  • Manually call action servlet from JSP

    Hi All,
    I have a struts form that uploads a file (which works perfect with no problem). IN this form i have a <html:submit> button.
    My problem is, if I have a field say Employer field; and i would like to search the employer address as soon as the focus leaves the employer text field and display it in the same form. I wrote a javascript onchange="javascript:getEmpaddress(this)"my javascript is:
    function getEmpaddress(objForm) {
         document.objForm.action = "/searchForm";
         document.objForm.submit();
    return true;
    }this form is not submitting... anyone having a clue on this?
    PS: for the the upload part, i have written seperate action & form
    for the employer search i worte seperate action & form
    and registered them both in my struts config file
    Regards
    smallpost

    You can call the servlet via RequestDispatcher (include or forward method):
    RequestDispatcher dispatcher=getServletContext().getRequestDispatcher("/servlet/ServletName");
    dispatcher.include(request,response);In the request you can store the data with setAttribute methode.
    And in the servlet you can get this data via request.getAttribute methode.
    Regards,
    Geri

  • Java calling a servlet...

    Hi,
    Is there a way to call a servlet from a Java standalone class (of course I want to pass to the servlet parameters and to retrieve results from the servlet) ?
    Thanks a lot.
    Regards.

    Hi Guru,
    Thanks for the reply.
    In my serlvet I wrote:
    response.getWriter().write("in the doGet method");
    In my Java class, I wrote the following :
                   URL url = new URL("http://server:port//Servlet1/theservlet");
                   BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                   String inputLine;
                   while ((inputLine = in.readLine()) != null)
                        System.out.println(inputLine);
                   in.close();
    I do get the String "in the doGet method".
    But what if I wanted to send Objects ?
    Is there a way ?
    I cannot user session of course....
    Any idea will be welcome.
    Thanks in advance.

  • Urgent!!!!!!!!!!Calling a servlet setting cookie

    Hi,
         The following is the complete picture of my problem. I am having a simple java servlet program in my domino server. (regarding the set-up's for executing the servlet program in the domino server....all are through...no problem over there...every thing is done, as per the guidence in the domino administration help).
         I want to contact my above said servlet program (in my domino server), from my simple java program (in my client machine). To contact the servlet program from my client machine, i am using the cookie generated by the BROWSER (Internet Explorer), as the entry in to the domino server. But still the servlet program is not getting executed.
         As far As the servlet execution from the browser ("http://192.168.10.12:8001/servlet/testing"), the servlet program is getting executed. But If I get the same cookie (DomAuthSessID) from the browser, using the "alert(javascript:document.cookie)"......and try to call the servlet from my java program, the servlet is not getting executed....could u pl. advice me for the above problem.
    Thanks and Regards
    Subha
    Java program for ur reference:(client machine)
    import java.io.*;
    import java.net.*;
    public class authen
         public static void main(String args[]) throws Exception
         try
              HttpURLConnection urlconnection = null;
              URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");          
              urlconnection= (HttpURLConnection)serverURL.openConnection();
              urlconnection.setDoOutput(true);
              urlconnection.setRequestMethod("POST");
              urlconnection.setFollowRedirects(true);
              urlconnection.setRequestProperty("Connection", "Keep-Alive");
              urlconnection.setRequestProperty("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");
              urlconnection.setDoOutput(true);
              urlconnection.setDoInput(true);
              urlconnection.setUseCaches(false);
              urlconnection.setAllowUserInteraction(true);
              urlconnection.connect();
         catch (Exception e)
              e.printStackTrace();
    Hope, the way I have called my servlet program "testing" from my client machine is correct.
    SERVLET PROGRAM (Which resides in the domino server)
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldExample extends HttpServlet
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
    System.out.println("####");
    System.out.println("### DOMINO AUTHENTICATION ####");
    System.out.println("####");
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException
    System.out.println("####");
    System.out.println("### DOMINO AUTHENTICATION ####");
    System.out.println("####");
    In the servlet.properties file, i have documented as,
    # HelloWorldExample properties
    servlet.testing.code=HelloWorldExample
    servlets.startup=testing

    Try to replace urlconnection.setRequestProperty
                ("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");with urlconnection.setRequestProperty
                ("Cookie","DomAuthSessID=AAE228AB68335546B277E9B375412A8A");Let me know if this solves your problem
    BG

  • How does a JSP page send data to a servlet?

    I know, elementary school question, but I can't seem to do it no matter what I tried to do. Here is my code:
           URL url = new URL("http://" + ChatGlobals.SERVER_NAME + "/" +
                    ChatGlobals.SERVLET_PATH + "/ppowell.ChatServlet?message=" +
                    URLEncoder.encode("/a " + cookieArray.getValue())
    out.println("<P>" + url.toString());
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setDoInput(true);     // NOT REALLY INTERESTED IN INPUT BUT MUST BE TRUE
    conn.setDoOutput(false);     // NO OUTPUT
    conn.setUseCaches(false);
    conn.setDefaultUseCaches(false);
    conn.setRequestProperty("Content-type", "text/plain");
         * Do servlet connection to retrieve from ChatServlet URL instance
         * by instantiating an InputStreamReader object
         * @see ChatServlet
    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String stuff = null;
    stuff = in.readLine();
    out.print(stuff);
    in.close();
    in = null;
    conn = null;
    Upon running this code my page just locks up.. URL: http://www.myjavaserver.com/~ppowell/chat.jsp
    But if I call the servlet directly:
    http://www.myjavaserver.com/servlet/ppowell.ChatServlet?message=/a+Phil
    Everything works perfectly, no lockups, no errors, the log and txt files are created. So if my browser calls the servlet everything is ok, but my JSP script in the same directory as my servlet is the one that needs to call the servlet.
    How then does a JSP send data to a servlet?
    Please help, I've been searching in books and online resources for days now with absolutely no apparent luck to do it.
    Thanx
    Phil

    It's correct that a JSP is compiled to a servlet. All HTTP servlets receive requests and send responses via HTTP, of course.
    But this JSP is making a URL connection to a servlet and sending data.
    Are you sure that the URL your JSP creates is identical to the one that works in your browser? Have you printed it out to stdout to verify that it's true? (Code inspection and "it looks right" doesn't count.)
    Why are you doing it this way? It's common to have a JSP send to a servlet, but the usual way of doing it is to put an HTML form in the JSP, including an HTML <input type="submit">, and POSTing the form data to a servlet URL. Why aren't you doing that? - MOD

  • How to call a servlet in new window without toolbar from OA page

    How to call a servlet in new window without toolbar from a OA page?Please provide sample code

    I have tried with the way suggested in Mukul's blog using javascript in Destination URI property.
    I tried to open a OA Page and from which forwarded it to a servlet..
    It is showing the error:
    Error Page
    Exception Details.
    oracle.apps.fnd.framework.OAException: The application id or shortname () you entered does not exist.
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1223)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1969)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:502)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:423)
         at oa_html._OA._jspService(_OA.java:86)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:175)
         at oa_html._OA._jspService(_OA.java:96)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    oracle.apps.fnd.framework.OAException: The application id or shortname () you entered does not exist.
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getAppId(OAWebBeanFactoryImpl.java:5391)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:969)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:502)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:423)
         at oa_html._OA._jspService(_OA.java:86)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:175)
         at oa_html._OA._jspService(_OA.java:96)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:534)
    oracle.apps.fnd.framework.OAException: The application id or shortname () you entered does not exist.
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getAppId(OAWebBeanFactoryImpl.java:5391)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:969)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:502)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:423)
         at oa_html._OA._jspService(_OA.java:86)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:175)
         at oa_html._OA._jspService(_OA.java:96)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:385)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:259)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:178)
         at oracle.jsp.JspServlet.service(JspServlet.java:148)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:534)

  • How to call a servlet from another servlet

    hi everybody,
    i have a problem, i have to call one servlet from another one.
    Everything works on my pc, but when i install the application on the customer's server i got an error about an Uknown URL followed by the name of the machine.
    Wjat i do is the folloqing :
    String urlString = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+servletName;
    URL url = new URL(urlString);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    the variable servletName is the name of the servlet i have to call.
    Is there another way to call the servlet ?
    All the servlet are installed in the same server.
    Any suggestion ?
    Cheers.
    Stefano

    Sweep is correct about requestDispatcher being another approach for inter-servlet delegation; the only issue that i recall with this approach is that it defaults the method of the destination servlet to the one it was called from...for example, calling servlet2 from within servlet1.post() resulted in the dispatcher attempting to utilize servlet2.post() - i believe that i searched for a parameterize solution to no avail :( (ended up handling the request by placing a "fake" doPost() in servlet2 that simply called servlet2.doGet())
    however, if your application is functioning correctly on your pc/webserver then the problem may be external to servlet communication (e.g. client webserver's ports not configured or blocked, missing runtime classes, etc.)
    my suggestion would be to set aside the programmatic concerns for the moment - what is the response if you open a browser on a client's machine and access the URL in question (i.e. http://clientserver:port/stefanoServlet)? If it will not respond to access in this manner then it certainly won't when your application calls for it.
    It's possible that there is a coding error but, given the info supplied, i'd start examining the environment, first. Let us know if you have any luck with the test i recommended or not (please provide abundant detail). Or, if you've found the solution then you may want to post back with a quick blub so the next person knows how to escape the trap.
    D

  • Weblogic 12c Servlet Response - Special characters show up as question mark

    My web app is running on Weblogic 12c (12.1.1) using WebWork + Hibernate. The program streams data (bytes making up a pdf) from a CLOB in an Oracle Database to the AsciiStream of the servlet output response. No exceptions are thrown, but the generated pdf contains blank pages. Comparing the bytes of the generated pdf, special characters are showing up as question marks.
    Some of the bytes read in from the database contain 8 bits (correct data), but the bytes that the servlet return contain only 7 (all bytes with 8 bits become "1111111"). The number of bytes returned from the servlet is correct.
    Code:
    //Response is HttpServletResponse
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "inline; filename=\"test.pdf\"");
    out = response.getOutputStream();
    byte[] buf = new byte[16 * 1024];
    InputStream in = clob.getAsciiStream();
    int size = -1;
    while ((size = in.read(buf)) != -1){
    // buf contains the correct data
    out.write(buf, 0, size);
    // other exception handling code, etc
    out.flush();
    out.close();
    "Correct" pdf byte example:
    10011100
    10011101
    1010111
    1001011
    1101111
    11011011
    Incorrect pdf byte example:
    111111
    111111
    1010111
    1001011
    1101111
    111111
    I have verified that the data read from the CLOB in the database IS correct. My guess is that the Weblogic server has some strange servlet settings that causes the bytes to be written to the servlet output stream incorrectly, or a character encoding issue. Any ideas?
    Edited by: 944705 on Jul 26, 2012 10:17 AM

    Solution found, I'll post the work around to those who might encounter the same problem.
    Somewhere in the layers of technology (webwork or weblogic I'd guess), the servlet response is encoded into UTF-8 regardless. The encoding in the database was ISO-8859-1. Sending ISO encoded bytes by UTF-8 caused the conflicting character codes (anything above 127) to show up as undefined.
    The fix is to decode the input byte array into ISO-8859 string, then encode that string into UTF-8, which can be send by Weblogic.
    isoConvert = new String(buf, "ISO-8859-1");
    out.write(isoConvert.getBytes("UTF-8"), 0, isoConvert.getBytes("UTF-8").length);

  • How to send  a request to servlet from a java client.

    I called a servlet from java client using URL object.
    I could establish a connection with server and display
    the content(like req.getservername etc.,)
    of servlet on client side(DOS prompt).
    My question is how do i send a request to servlet from the client.
    let me say, i have to send a value as 10 to servlet and do some processing
    ( like 10*2 = 20) display the output (20) on client side..
    It will be appreciated if u can mention the syntax...

    just add the query string to the url you use to create the URL object from.

  • Converting emails to servlet requests; servlet responses to emails

    Hello,
    I had asked this question in the Servlet forum. They directed me to here.
    I've some servlet applications that posted by HTML forms with file attachements and other HTML fields.
    I want to add email support to my servlets. So, users should be able post and recieve their data by emails.
    But, I don't want to add email handling tasks to the current servlet applications. I need a middleware application between end users and my servlets that converts emails to servlet requests, and servlet responses to emails.
    Here are the steps:
    1- End user sends email with attachments.
    2- Emailed data is converted to servlet request by a middleware application.
    3- Servlet request is processed by my current servlets.
    4- Servlet response is sent to middleware application.
    5- Middleware application emails servlet reponse to end user as email.
    If I can do that, I will not have to add emailing codes to my current servlets. do you know a product doing that ? Or, can you give me a direction ?
    thanks...

    Have you looked into JMS?

Maybe you are looking for