How to redirect url in servlet?

in servlet, i want to redirect page to a url which not in same container, and send to some information to this url, what shall i do?
thanks.

duffymo's solution should do it, then.
You could build on top of that and send serialized data (I'm assuming your data is serializable) over the wire to the other server using an HttpUrlConnection and ObjectOutputStream's writeObject(), and read it at the other end with ObjectInputStream's readObject(). For example for the write operation :
URL url = new URL(other_server_url);
HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
// after setting urlcon attributes like requestMethod to POST etc...
ObjectOutputStream out = new ObjectOutputStream(urlcon.getOutputStream());
// now write the data, then flush & close the connection
...If the amount if data to transfer is quite large, you could again build on top of the above and use CompressedSerialization :
http://robowiki.dyndns.org/perl/robowiki?CompressedSerialization

Similar Messages

  • GRC 10 - SSO via Portal - how to redirect url in notification variables

    Dears,
    I am in the process of designing our GRC 10 machine to be accessed via SSO in the Enterprise Portal. Yet I cannot find any info on what will happen with the URLs that are placed by ARM MSMP workflow in the variables of notifications/approvals.
    I typically would (as in 5.3) expect a redirect URL to be made available as an option.
    As an example: the Firefighter Log notification standard holds a variable pointing the URL to :
    http://GRC10server:GRC10port/sap/bc/webdynpro/sap/grac_ui_spm_log_email?sap-client=001&sap-language=EN&WF_ID=53FB8FEAC9E260D6E10000000AF90C44&APP_TYPE=1
    Yet now with SSO via the portal we also want this URL to go via the portal instead of directly to the GRC machine. How can we achieve that?
    Is there a configuration way to have GRC10server:GRC10port adjusted to the portal address..
    (mind that the WF_ID segment in this url is dynamically generated, so directly sqeezing in a static portal url is not an option)
    Cheers,
    Jim

    Hi Neeraj,
    Thx for your reaction. This unfortunately will not do the job as pasting the URL in the notification template will make it static. The problem is that the URL inserted by default is a dynamically created one which holds a variable pointer to a workflow object id.
    Now i am researching if a custom build portal redirect application will do the job. But there must be others having the same problem if you want the GRC iview in the portal to be the 'one-stop-shop' for your GRC users...
    Cheers,
    Jim

  • How to redirect URL?

    Our lab uses Xserve to host our web pages. We want to redirect URLs (without showing real web folder details) when users surf on our web site. For example:
    Our web site host name: www.labname.edu
    We want that users only see "www.labname.edu" on the browsers, instead of showing "www.labname.edu/folder1/subfolder1/.../filename1.html" or "www.labname.edu/folder2/subfolder2/.../filename2.html"...etc.
    I am a new bee for Xserve and do not know how to resolve this task. I will appreciate any suggestion. Xserve admin provides URL aliases and redirects. Is it possible to use that to resolve my problem. Does anyone can teach me how to set up "type", "pattern" and "path"?
    Thanks in advance!

    What you're asking for is not trivial to do; you're basically usurping how the file-based presentation works, which means you're going to be writing some code. Simple redirects are easy, but they don't provide your required transparency with the target files, and the scheme doesn't scale all that well. The hack approach is to use file (or directory) links; the ln command and related. This gets ugly to maintain. The "big hammer" approach is to load the content into a content management system (CMS; eg: Drupal, Wordpress), and let the CMS manage all this stuff for you.

  • How to return URL of servlet path ?

    Hello,
    I want to return the URL of current servlet path (such as "http://www.mydomain.com:888/servlet"). How can I do that ?
    thanks in advance...

    Hi danisment,
    Checkout the API for javax.servlet.http.HttpServletRequest Interface in which you have the methods to get path information.
    Use
    request.getServletPath();Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.
    If you want the entire URL,
    use request.getRequestURL(); returns the StringBuffer
    The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters
    Hope this will throw some light for you problem.
    Thanks,
    Sanath Kumar

  • How to redirect all Tomcat request to a servlet

    How can I set up Tomcat to redirect all request to a certain sevlets which sends the user to the right web-application.
    What ever the user type in the URL, i.e.:
    http://customer01.myDomain.dk
    or
    http://customer02.myDomain.dk
    or
    http://customer01.myDomain.dk/myApp/login.jsp
    - I want tomcat to redirect to a servlet class. Is that possible?
    Thanks

    Yes but pretend each customer has more than one web-application. Then it is not possible for the customer to use only this URL:
    http://customer01.myDomain.dk
    Each customer need a seperate url for each application, something like this:
    http://customer01.myDomain.dk/myApp01/login.jsp
    http://customer01.myDomain.dk/myApp02/login.jsp
    ( easy URL�s they can remember )
    And I don�t think it is possible to make an alias to the exact URL to the web application. That�s why I need Tomcat to redirect all request to i.e. Index.jsp which then redirect to the correct application.
    Here is an example:
    Customer01 type in:
    http://customer01.myDomain.dk/myApp01/login.jsp
    Tomcat calls Index.jsp which redirect to this URL:
    http://www.myDomain.dk/myApp01_ID0921/login.jsp
    Can you help me with this problem?

  • How to call two different servlet-url in the same application

    Hi,
    I want to call, consecutively these methods in my application.
    response.sendRedirect(servlet-url1)
    reponse.sendRedirect(servlet-url2)
    but the second method dont answer,
    I think, the first method redirect s with response ,
    but how to call two different servlet ?
    thanks

    if you call the first redirect, the servlet is getting aborted, so you can redirect to the first servlet, working the stuff in it, and then in the second servlet you can redirect to the third servlet

  • How to display swf in full screen mode and how to redirect to a url

    Hi,
    I have 2 questions :
    Question 1 - I have a flash swf file and I want to display it in the browser in full mode meaning it should fit the browser, I have tried adding
    fscommand("fullscreen", "true");
    in the first frame of a lyaer but it does not work.
    Question 2 - How to redirect to another page at the end of the swf movie, I have tried adding :
    stop(); 
    navigateToURL( new URLRequest("*www.microsoft.com*"), "_self");
    in the last frame but it does not work.
    Thank you very very much for your assitance !!
    Terry

    "fscommand("fullscreen", "true");" only works for self-running executables, not embedded SWFs in a web page.
    To get the swf to fill the browser page, the best thing to do would be to adjust the publish settings of the "HTML Wrapper" page and copy the necessary pieces from the resultant HTML file into the HTML file you are putting the swf into.
    I have had some successes dealing with similar navigation issues by breaking up the code into multiple tasks:
    var url:String = "http://www.microsoft.com";
    var urlReq:URLRequest = new URLRequest(url);
    navigateToURL(urlReq);
    I can't guarantee that will help, but at least I tried.  :-)

  • Redirecting URL Servlet not working

    Hi all,
    All my JSPs are located in pages folder of my Application's Web Context. I need to redirect JSP URLs to the pages folder. For example if user requests http://localhost:8080/RedirectJSPApp/test.jsp then I need to redirect to http://localhost:8080/RedirectJSPApp/pages/test.jsp. But if user request http://localhost:8080/RedirectJSPApp/pages/test.jsp then i dont need to do any redirection.
    So I define a Servlet:
    package com.srh.servlet;
    public class RedirectServlet
          extends javax.servlet.http.HttpServlet
       public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException
          doPost(request, response);
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException
          String contextPath = request.getContextPath();
          String requestUrl = request.getRequestURL().toString();
          String targetRequestUrl = null;
          String jspRequested = null;          
          int index = -1;
          index = requestUrl.indexOf("/pages/");
          // The JSP is not called properly;
          if (index == -1)
             // Call the JSP properly
             index = requestUrl.indexOf(contextPath);
             if (index != -1)
                targetRequestUrl = requestUrl.substring(0, index+contextPath.length());
                jspRequested = requestUrl.substring(index+contextPath.length()+1);
                targetRequestUrl += "/pages/" + jspRequested;
                response.sendRedirect(targetRequestUrl);
    }In the web.xml I wrote:
       <servlet>
          <description>This Servlet redirects JSP URLs to appropriate lcoation w.r.t. Server</description>
          <display-name>RedirectServlet</display-name>
          <servlet-name>RedirectServlet</servlet-name>
          <servlet-class>com.srh.servlet.RedirectServlet</servlet-class>
       </servlet>
       <servlet-mapping>
          <servlet-name>RedirectServlet</servlet-name>
          <url-pattern>*.jsp</url-pattern>
       </servlet-mapping>I have a test.jsp in pages folder:
    <html>
       <head>
          <title>Test</title>
       </head>
       <body>
          Inside test.jsp
       </body>
    </html>I deployed on JBoss 4.2.0. I type http://localhost:8080/RedirectJSPApp/test.jsp in my browser and it changes to http://localhost:8080/RedirectJSPApp/pages/test.jsp which is perfect but it never prints "Inside test.jsp" on the page. Why this is happening?
    If I remove RedirectServlet entries from web.xml and just type in http://localhost:8080/RedirectJSPApp/pages/test.jsp then it prints "Inside test.jsp" on the page. What I am missing here?
    TIA
    TV

    I tried forward of RequestDispatcher but still same problem:
    package com.srh.servlet;
    public class RedirectServlet
          extends javax.servlet.http.HttpServlet
       public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException
          doPost(request, response);
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException
          String contextPath = request.getContextPath();
          String requestUrl = request.getRequestURL().toString();
          String targetRequestUrl = null;
          String jspRequested = null;          
          int index = -1;
          index = requestUrl.indexOf("/pages/");
          // The JSP is not called properly;
          if (index == -1)
             // Call the JSP properly
             index = requestUrl.indexOf(contextPath);
             if (index != -1)
    //          targetRequestUrl = requestUrl.substring(0, index+contextPath.length());
    //          jspRequested = requestUrl.substring(index+contextPath.length()+1);
    //          targetRequestUrl += "/pages/" + jspRequested;
    //          response.sendRedirect(targetRequestUrl);
                jspRequested = requestUrl.substring(index+contextPath.length()+1);
                RequestDispatcher rd = request.getRequestDispatcher("/pages/" + jspRequested);
                rd.forward(request, response);
    }

  • How does c:url tag know when the session is cookieless and thus to redirect

    i have been looking at the source code for c:url tag and can't figure out how they are doing that. I need a way to do that in a jsp, to check if the cookies are allowed or not.

    how does c:url tag know when the session is cookieless and thus to redirecthuh?
    What do cookies have to do with redirecting?
    Cookies get encoded into a URL using the method in HttpServletResponse: response.encodeURL() or encodeRedirectURL().
    That method determines whether or not it prints out the session id as part of the url, or it gets uses cookies.
    You can try: request.isRequestedSessionIdFromCookie().
    If that is true, you know that session cookies are supported (or at least that one was)

  • Getting Warning about Redirection url

    Hi,
    we have the the portal application running on the weblogic 11g and upon login, home page of our app is loaded, but I do see the following warning message on the portal server logs. Any idea how we can supress this warning?
    <Warning> <netuix> <BEA-423420> <Redirect is executed in begin or refresh action. Redirect url is https://<servername>.arccorp.com:443/PortalApp/ARCGateway.portal?_nfpb=true&amp;_st=&amp;_pageLabel=ARC_Home&amp;_nfls=false
    Thanks
    sravi

    Hi Sravi,
    I am not sure if this is your situation or not, but hopefully it could be helpful for you.
    It is not supported for a remote pageflow portlet (WSRP producer) to redirect from its pageflow begin or refresh action. Because of this limitation, WebLogic Portal logs a warning when any portlet's pageflow attempts to redirect from either of these two actions.
    It is legal to redirect from these actions if the portlet is not a WSRP producer. If this is the case, Oracle has added a utility method that can be called prior to the redirect which can suppress these warning messages:
    - Class: com.bea.netuix.servlets.controls.content.PageflowLoggingHelper
    - Method: public static void dontLogRedirectWarning(HttpServletRequest req)
    Calling this method from the pageflow's begin or refresh action prior to the redirect will suppress the Netuix redirect warnings.
    Thanks,
    Cris

  • How to call URL to collect user input ?

    Hi all,
    I am writing a Swing applications and at some points, I need to call a URL (external web page) to collect user input. It invokes passing certain parameters to web page so that the web page can be displayed in some certain form. After the user input all data in web page, press "submit", my Swing application needs to get the input back. I suppose that calling URL is trivial but how can I get the input back ? Any input will be greatly appreicated.
    Note: the web page will be displayed in one JFrame but it may not related to this problem.
    C.K.

    response.sendRediresc("http://.......);
    public void sendRedirect(java.lang.String location)
                      throws java.io.IOException
        Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.
        If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
        Parameters:
            location - the redirect location URL
        Throws:
            java.io.IOException - If an input or output exception occurs
            java.lang.IllegalStateException - If the response was committed or if a partial URL is given and cannot be converted into a valid URL

  • How to redirect users to another address

    Hi
    Thank you for reading my post
    I have a problem that i do not know how to resolve.
    we had an application in an address like :
    http://www.myweb.com/web2/ it is a dynamic application written in java .
    now we move it to another server like : http://10.10.a.b/web2/
    we need all people that come to the first address to be redirected to new address with the complete url for example if some one come to http://www.myweb.com/web2/register.jsp
    we should be able to redirect him/her to http://10.10.a.b:8888/web2/register.jsp
    what should i do now ? is there any way that i can do this ?
    i am allowed to deploy a java web application to first address to do this , i mean i can deploy some java web application to http://www.myweb.com/web2/ to make this redirection possible.
    does any one hav an idea ?
    thanks

    Certainly sounds possible.
    Put in a servlet filter that will intercept all requests.
    You would use response.sendRedirect to send the redirect.
    However what you would lose in this redirect is any request variables. You would have to include them as get parameters in the redirect URL which
    - may not be secure
    - may not work if there are too many request parameters.

  • Redirect to a servlet when using a proxy

    Hello,
    How can I redirect to a servlet from a jsp without hardcoding any directory/parts of the url?
    I am using tomcat v.3.2.1.
    The webapp is behind a proxy server and that address can change so when the real url to a jsp called myjsp.jsp would be something like "www.host.com/webapp/myjsp.jsp", it is now proxied to something like "www.otherhost.com/somenicedir/otherdir/webapp/myjsp.jsp" now the proxy part ("www.otherhost.com/somenicedir/otherdir") can change and I need to know how to redirect from a jsp to a servlet without hardcoding the proxy part.
    If I redirect from a jsp to a jsp I can just do it with sendRedirect("otherjsp.jsp") since it is in the same folder. But for a servlet, since it is in a different folder the redirect would be something like sendRedirect("/servlet/myServlet") but when I send that with a proxy, it goes to "www.otherhost.com/webapp/myjsp.jsp" and then it gives you error page not found since it is missing the dirs in between.
    So how do I make a clean redirect from a jsp to a servlet inside the same webapp without it getting redirected to some wrong address if its proxied?
    -teka

    Thanks for the tip, it seems to give the address of the real server though, not the proxied one.
    I was wrong about the redirection though, it was from a servlet I need to redirect to a jsp not the other way around.
    Seems like redirecting to /webapp/servlet/servletname works but now i need a way to redirect to a jsp from a servlet with a relative path or some other way to pass the beginning of the URL which can change.. Any ideas anyone?
    -teka

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How to redirect to different page after login in APEX 4.1

    Dear All,
    Here my Requirement is,When the users login,
    when they entered their username and password and pressed login button,
    they have to redirected to different pages based on the type of user.
    Here my LOGIN_TABLE has following 3 columns,
    1.Username
    2.Password
    3.Type.
    The TYPE has 2 values, employee and admin.
    when the type is admin they should be redirected to page 2,
    reaining i.e employee users has to be redirected to page 3.
    How can I do this? please give some suggestion.
    Thank you.
    regards,
    Gurujothi

    Dear Christian,
    Thank you for your reply,
    I would like to explain something,
    When I using the following function,
    *create or replace FUNCTION custom_auth_g (
    p_username IN VARCHAR2,
    p_password IN VARCHAR2)
    RETURN BOOLEAN IS
    BEGIN
    FOR c1 IN (SELECT 1
    FROM login_table
    WHERE upper(username) = upper(p_username)
    AND upper(password) = upper(p_password))
    LOOP
    RETURN TRUE;
    END LOOP;
    RETURN FALSE;
    END;*
    When login, It checks in the login_table table and if the username is exist with the pass word it successfully entered inside the application.
    for all users only one page which we set.
    My Login_table also contains type which has 2 type as I mentined above.
    But As I mentioned earliar based on the user type it has to be redirected to 2 different page.
    I found this Package but I cant understand,Can you please Explain?
    *create or replace PACKAGE app_security_pkg
    AS
    PROCEDURE add_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    PROCEDURE login
    p_uname IN VARCHAR2
    ,p_password IN VARCHAR2
    ,p_session_id IN VARCHAR2
    ,p_flow_page IN VARCHAR2
    FUNCTION get_hash
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    RETURN VARCHAR2;
    PROCEDURE valid_user2
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    FUNCTION valid_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    RETURN BOOLEAN;
    END app_security_pkg;*
    *create or replace PACKAGE BODY app_security_pkg
    AS
    PROCEDURE login
    p_uname IN VARCHAR2
    ,p_password IN VARCHAR2
    ,p_session_id IN VARCHAR2
    ,p_flow_page IN VARCHAR2
    IS
    lv_goto_page NUMBER DEFAULT 1;
    BEGIN
    -- This logic is a demonstration of how to redirect
    -- to different pages depending on who successfully
    -- authenticates. In my example, it simply demonstrates
    -- the ADMIN user going to page 1 and all other users going
    -- to page 2. Add you own logic here to detrmin which page
    -- a user should be directed to post authentication.
    IF UPPER(p_uname) = 'ADMIN'
    THEN
    lv_goto_page := 1;
    ELSE
    lv_goto_page := 2;
    END IF;
    APEX_UTIL.SET_SESSION_STATE('FSP_AFTER_LOGIN_URL');
    wwv_flow_custom_auth_std.login
    p_uname => p_uname,
    p_password => p_password,
    p_session_id => p_session_id,
    p_flow_page => p_flow_page || ':' || lv_goto_page
    EXCEPTION
    WHEN OTHERS
    THEN
    RAISE;
    END login;
    PROCEDURE add_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    AS
    BEGIN
    INSERT INTO app_users (username, PASSWORD)
    VALUES (UPPER (p_username),
    get_hash (TRIM (p_username), p_password));
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    ROLLBACK;
    RAISE;
    END add_user;
    -- Function to Perform a oneway hash of the users
    -- passwords. This cannot be reversed. This exmaple
    -- is a very week hash and if been used on a production
    -- system, you may want to use a stronger hash algorithm.
    -- Read the Documentation for more info on DBMS_CRYPTO as
    -- this is the supported package from Oracle and
    -- DBMS_OBFUSCATION_TOOLKIT is now depricated.
    FUNCTION get_hash (p_username IN VARCHAR2, p_password IN VARCHAR2)
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN DBMS_OBFUSCATION_TOOLKIT.md5 (
    input_string => UPPER (p_username)
    || '/'
    || UPPER (p_password));
    END get_hash;
    PROCEDURE valid_user2 (p_username IN VARCHAR2, p_password IN VARCHAR2)
    AS
    v_dummy VARCHAR2 (1);
    BEGIN
    SELECT '1'
    INTO v_dummy
    FROM app_users
    WHERE UPPER (username) = UPPER (p_username)
    AND PASSWORD = get_hash (p_username, p_password);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN raise_application_error (-20000, 'Invalid username / password.');
    END valid_user2;
    FUNCTION valid_user (p_username IN VARCHAR2, p_password IN VARCHAR2)
    RETURN BOOLEAN
    AS
    BEGIN
    valid_user2 (UPPER (p_username), p_password);
    RETURN TRUE;
    EXCEPTION
    WHEN OTHERS
    THEN RETURN FALSE;
    END valid_user;
    END app_security_pkg;*
    And you said "assign an URL to FSP_AFTER_LOGIN_URL, depending on the Type column",
    Where to assign,Could you please Explain?
    Thank you.

Maybe you are looking for

  • Existing Quality Notification takes long time to open for certain vendors

    Hello Gurus, I have users complaining about the wait time( 2 t0 5 mintues) when opening of an Quality notification in QM03 for certain vendors. For soem vendors its fast and they always fast but for some it takes really long time and it always long.

  • Data loss in the secure file transfer using java

    Hi, My java Appllication uses the sftp(secure file transfer protocol) for file transferring. when the load is high like 150 GB , data loss occuring for some files especially last chunk of data is missing. Core file transfer code while (true) int read

  • Tfr photos from computer to Ipad2

    Is there a way to transfer photos from a windows7 pc to my Ipad 2?  I've tried many ways but no luck so far.

  • Install Windows server 2012 using powershell

    Hi Folks, How to Install Windows server 2012 using powershell. Thanks,

  • SM37 - Output screen

    Hi  , I want to make SM37 output screen as display only. User should not be able to do any changes/delete/create to the existing jobs or spools. Is it possible using Transaction variant? because the output of SM37 screen doesnt have Screen number ass