Calling a servlet from XSQL

Has anyone successfully called a servlet from xsql? If you have, have you called one from the href in the xsl:stylesheet?
null

Can you post a sample of what you're trying to do? Not sure what you mean by having the XSQL "call a servlet"? Call a servlet when? to serve/use what?
Are you trying to using a servlet to return a dynamically-constructed stylesheet in the role of:
<?xml-stylesheet type="text/xsl" href="http://foo/servlets/myservlet"?>
If not, can you expound on what you're trying to achieve/accomplish?
Thanks.

Similar Messages

  • 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

  • How can i call a servlet from a servlet ?

    Hello,
    Can i call a Servlet from within a Servlet ?
    and is it "right thing" to Do ?
    Thanks

    JMO, but I wouldn't do it like this.
    Don't have a remote object like a servlet doing database queries for your app. That will mean TWO network hops for every query if the database resides on another machine. The network is the biggest bottleneck you've got.
    Write a JavaBean that does the database stuff for you and just have the first servlet instantiate it when it needs it. A Bean has a better chance of being reused, too. Write a TableGateway or DAO for your object.
    Or write an EJB to do it.
    The only time I've done a servlet-to-servlet connection like that was for one servlet running in a DMZ that would authenticate a user and then forward the request to another servlet running inside the second firewall.
    I wouldn't encapsulate database query logic in a servlet like that. JMO - MOD

  • Help needed to call a servlet from an applet

    Hi,
    can someone help me with the way to call a servlet from an applet.
    actually on click of a button i wanna call my servlet and save some data in DB.
    i am not able to call my servlet. see the sample code which i am trying..
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("Upload")) {
    try {
    System.out.println("Upload button has been clicked -----------");
    URL url = new URL("http://localhost:8084/uploadApp/TestServlet");
    URLConnection urlConnection = url.openConnection();
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    ObjectOutputStream objOut = new ObjectOutputStream (urlConnection.getOutputStream());
    objOut.writeBytes(userId); // pass parameter to servlet
    objOut.flush();
    objOut.close();
    } catch (MalformedURLException ex) {
    Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
    Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
    is there any problem with the code? please suggest.

    hii,
    checkout my add from, HTH
    [http://forums.sun.com/thread.jspa?threadID=5419921&messageID=10885709#10885709]
    ... kopik

  • Calling a servlet from a servlet?

    Is it possible to call one servlet from another servlet?

    You should use servlets to process requests. If what you're asking for is to execute a piece of logic within a servlet before its finished processing the request, then you should consider using a regular java class instead of a servlet. If you just want to send the request information to another servlet you can use getRequestDipatcher().forward(..) method. Keep in mind that by doing so you'll interupt the current servlet.
    Regards,
    D.

  • Calling a servlet from another servlet?

    Hi
    I would like to know that how can I call one Servlet from another Servlet. I have tried getServlet() method of ServletContext but it has been deprecated. I want to call a specific method of the other Servlet, is there any other way?
    Thanks

    I should have seen it from your previous post :(
    Code of Servlet 1:
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws
    ServletException, IOException
    RequestDispatcher rDispatch = null ;
    rDispatch = getServletConfig
    ().getServletContext().getRequestDispatcher
    ("/Servlet2") ;
    rDispatch.forward(request, response) ;
    System.out.println("Back in 1");
    I assume Servlets 1and 2 are in same web app and you've mapped your servlet2 to /Servlet2 in your web.xml
    make it as
    rDispatch = request.getRequestDispatcher("/Servlet2");
    rDispatch.forward(request,response);
    Nothin's wrong with yer servlet2

  • Calling a servlet from java

    How to call a servlet from java?
    your help is greatly appreciated..

    Welcome to the forum
    You seem to be misunderstanding something. Do some googling to learn what you need about servlets. Simplified, servlets are java code that's hosted by a web container, such as Tomcat. When a servlet gets called as a consequence of someone requesting a url from the container, it takes in a request object and a response object. All the magic is then in creating an appropriate response (e.g. html) for the incoming request.

  • Call a servlet from Faces Portlet in Websphere

    Hi All,
    I have created a JSR-168 Faces Portlet project and using RAD(IDE) and WebSphere Portal server.
    I want to call a servlet from my jsf portlet.But i do not know where to place my servlet in the project directory.And how to invoke a call to my servlet from my portlet.
    Please help me find an answer.
    Best Regards,
    Pallavi

    hi Pallavi,
    Yes you can do that, what you have to do is you can get the ExternalFacesContext and forward your request to the servlet, you have entry for your servlet in web.xml...
    I am sure about it but you can try this
    Hope it will work.
    Surya

  • Calling a servlet from a Java Stored Procedure

    Hey,
    I'm trying to call a servlet from a Java Stored Procedure and I get an error.
    When I try to call the JSP-class from a main-method, everything works perfectly.
    Java Stored Procedure:
    public static void callServlet() {
    try {
    String servletURL = "http://127.0.0.1:7001/servletname";
    URL url = new URL(servletURL);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestProperty("Pragma", "no-cache");
    conn.connect();
    ObjectInputStream ois = new ObjectInputStream(conn.getInputStream());
    Integer client = (Integer)ois.readObject();
    ois.close();
    System.out.println(client);
    conn.disconnect();
    } catch (Exception e) {
    e.printStackTrace();
    Servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    Integer id = new Integer(10);
    OutputStream os = response.getOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(id);
    oos.flush();
    oos.close();
    response.setStatus(0);
    Grant:
    call dbms_java.grant_permission( 'JAVA_USER', 'SYS:java.net.SocketPermission','localhost', 'resolve');
    call dbms_java.grant_permission( 'JAVA_USER','SYS:java.net.SocketPermission', '127.0.0.1:7001', 'connect,resolve');
    Package:
    CREATE OR REPLACE PACKAGE pck_jsp AS
    PROCEDURE callServlet();
    END pck_jsp;
    CREATE OR REPLACE PACKAGE BODY pck_jsp AS
    PROCEDURE callServlet()
    AS LANGUAGE JAVA
    NAME 'JSP.callServlet()';
    END pck_jsp;
    Architecture:
    AS: BEA WebLogic 8.1.2
    DB: Oracle 9i DB 2.0.4
    Exception:
    java.io.StreamCorruptedException: InputStream does not contain a serialized object
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java)
    The Servlet and the class work together perfectly, only when I make the call from
    within the database things go wrong.
    Can anybody help me.
    Thank in advance,
    Bart Laeremans
    ... Desperately seeking knowledge ...

    Look at HttpCallout.java in the following code sample
    http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/jwcache/Readme.html
    Kuassi

  • Calling a Servlet from a JSP within Portal Portlet

    We've created a JSP that calls a Servlet when the form is submitted. The servlet handles the request, does some basic processing and then forwards back to a JSP. This works fine outside of Portal.
    What needs to be done in order for this to work within a portlet in Portal? We can get to the first JSP which is in a portlet, but as soon as we click the submit button (which tries to call the servlet) we get the basic page not found error. We need to click the button, go to the servlet and have the servlet forward back to our portlet.
    I know this is not the ideal way of using Portal however...
    Any ideas?
    Thanks!
    -Teri Kemple
    [email protected]

    I was wondering is there any way I can call a servlet from jsp? There are two scenarios here
    1 - if the jsp is currently being executed/evaluated on the server, then you can use <jsp:include> to "call" a servlet, or <jsp:forward> to cancel the jsp and transfer the control to the servlet.
    2 - if the page is already loaded and running in the client, then the only way to call a servlet is making a HTTP request as from any other html page. Jave code does not execute on the client, so you have to use html/javascript at that point.
    Calling a servlet within another servlet.
    lets say one servlet maintains all dynamic html. I call this servlet from another servlet to create a dynamic page and then insert values into it.Close, but the standard pattern is the reverse of that. What normally happens is you retrieve the values to put in the page, and then call the page, passing in those values. Thats why often you get a servlet/actionbean getting called, which then forwards to a JSP to display the result. The servlet/bean loads all the values required into scope, and then the JSP presents the data.

  • Question? calling a servlet from EJB.

    Can anyone tell me how I would go about calling a servlet
    from a session bean that’s running in the same J2EE application.
    Application server is Oracle10g.
    Thanks.

    Welcome to the forum
    You seem to be misunderstanding something. Do some googling to learn what you need about servlets. Simplified, servlets are java code that's hosted by a web container, such as Tomcat. When a servlet gets called as a consequence of someone requesting a url from the container, it takes in a request object and a response object. All the magic is then in creating an appropriate response (e.g. html) for the incoming request.

  • Calling second servlet from first servlet

    I need to call a servlet from a servlet.
    I need to call the specific doGet method of servlet 2 from
    servlet 1. I also need to return the control to servlet 1
    after servlet 2 done its job.
    I did it now by creating a new instance of servlet 2 from servlet1
    and then call the doGet method like
    in servlet1 : Servlet2 serv2 = new Servlet2();
    I really don't like this idea of creating a new instance in servlet 1.
    Any thoughts/idea/comments would be appreciated.

    request.getRequestDispatcher("path/to/otherServlet").forward(request, response);
    or
    request.getRequestDispatcher("path/to/otherServlet").include(request, response);will do what you are looking for. See the API documentation on details. Basically the difference is that forward gives FULL control (including that of the headers) to the invoked servlet while include mearly "includes" the results.

  • Problems calling Java Servlets from HTML pages Online

    Hello
    I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
    http://localhost:8080/servlet/....
    followed by the name eg.
    http://localhost:8080/servlet/Login
    however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
    i.e ..servlet/Login.java
    I was wondering would anyone have any idea as in how the servlets should be called
    Thanks very much

    Once you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
    -Mak

  • Calling One Servlet From Another

    Thanks in advance for any advice!
    I would like to call servletB from servletA then use the response returned from servletB within the processing of servletA.
    I have checked the forums and jGuru but nothing I've found really matches the problem. RequestDispatcher has "forward" and "include" but I do not want to include the reponse from the called servlet in the response of the original one.
    Here is the situation. I have a web application that uses an applet front-end using a mainframe datasource. The applet displays data in various JTables and prints various reports.
    The applet calls a servlet(B) with an SQL statement in the request that responds with a Vector of data to be displayed in the JTable. This is working fine.
    The applet also calls servlet(A) which uses iText from SourceForge to create a PDF report that is sent back to the browser for display in Adobe Reader. This also works fine.
    Because I cannot figure out how to call servletB from within servletA, my current workaround is to embed the code of servletB inside servletA. Not very good OOP and as the application grows maintaining this will become a problem.
    Any suggestions would be greatly appreciated.
    Max

    Why don't you just take the code that the applet uses to "call" servlet B and replicate that code into servlet "A"? (Or better still, create a class to do that, which could be called both from the applet and from servlet A.)

  • Calling a servlet from HTML

    Is it possible to call a class/servlet from a front-end web page (web page is in HTML form not java form) given that I created my servlet to be executed per class? If there is, can you give me a sample code snippet on how to do this?
    An example on how I call a class in my servlet:
    coordinate c = new coordinate();
    boolean a = c.plot(x,y);
    //do somethingBackground:
    I have already finished creating the server side code for a website and I chose to call a class inside the doPost() method. The class called will be responsible for executing the logic.
    The problem arrives when the web designer created a webpage that requires more than 1 function to be called per page. Since I'm using doPost() which requires the form to be submitted, is there a way to know which submit button is clicked and thus execute the correct function?
    I have a plan that I can fall back to which is to change my code so that it will read variables from the URL instead of thru a method call, but it will take more time since there are a lot of methods. I just thought I ask here if there is a way to accomplish the above so that I can save my code from this mess.
    Thanks,

    My servlet is structured in a way that it calls a method with values that it acquires from the webpage. (The initial plan was to enclose the HTML inside a servlet, but was changed so now I need to incorporate my servlets/services inside the HTML)
    Like in my example, on the coordinate class x and y are acquired from input boxes located in the web page then invoked the method plot(x,y). Since it will be HTML main and servlet sub, I need a way to call plot(x,y) from an HTML page. Or are you saying that my option would be to just create an intermediary servlet that would acquire the input and then call my class to process.

Maybe you are looking for

  • My screen broke how can i get apple to fix it i can find where it tells u they fix screens

    hello my screen is broken and i can find how to get it fixed on the apple web site they have no catagory for it saying screen repair i just put random things and where it says put in a detail descripton i said i needed my glass reapired and i said th

  • Pricing condition question

    Hi Gurus, I need your help 1) Want to configure a pricing condition which can be used only in a purchase order, but NOT in a contract/outline agreement. Is it possible? If yes, then how? 2) Want to configure a pricing condition which when added in a

  • Macbook startup problem

    My macbook will startup only in save boot mode - otherwise it either comes to the login screen and nothing happens or I don't get the login option, only the apple logo and the cursor. . . it worked fine yesterday on the train, since I've neither inst

  • Radius Support for AAA

    I have a number of 3500XL and 2950 switches in the Enterprise. I was hoping to get away with MS Radius to control Authentication to the switches. I know these switches supported TACACS+. They do not seem to support Radius. Is there a certain revision

  • What is this converter.dSYM folder in my application folder?

    Hello, I noticed a new folder titled "converter.dsym", which contains another folder called "dwarf". The latter contains  file called "converter". No filename extension. Does it sound familiar to you ? It's exactly as in this thread. https://discussi