Servlet redirecting at Server side

Hi,
I need to redirect to a Servlet on another Servlet.
response.sendRedirect("http://www.xyz.com/servlet/customerserviceServlet.TestServlet.do");
I need to pass some request parameter. I know one method is to pass the parameter through the URL.
However due to some security constraints I cannot use this method.
Is there an alternate approach to this? Can I send the parameters using Header. If yes, then how?
Thanks!!

You cannot. Besides, being able to modify the header is just as big a security risk as sending the parameters as part of the url. Any idiot can install a packet sniffer and see what is inside the header. Perhaps encrypting the parameters is better?

Similar Messages

  • Refreshing the Servlet on the Server side???

    Hi,
    Can we refresh a servlet page on the server side without using response.sendRedirect()???

    Hello,
    I just had a look at www.pushlets.com, looks an interesting idea, and relatively easy to do.
    Correct me if I am wrong, but the examples I looked at were not reloading the page, rather, they create a page that takes a long time to load, and keep streaming more data to it.
    What they are doing is putting the thread to sleep, so the page never loads fully, instead continually updating.
    The problems with this would seem to be that you could append more data to the page, but not be able to delete information already in the browser.
    I am also unsure what would happen in the event the user closes the browser, I assume the jsp would keep trying to send data until the session expired.

  • Weirdness involving IE, JSP, data scraping and server-side redirecting

    I have a JSP script that validates inputted data. Upon successful input, it will
    1) set a cookie
    2) Do a data scrape to a URL that points to a servlet that performs server-side actions based upon query string data that is formed from your input
    3) Redirect back to itself to ensure cookie availablity and further actions.
    If you run this script on Netscape or Firefox, all is well.
    If you run this script on IE, while [2] works, it seems to be performing [2] twice, because the actions are duplicated (the actions in [2] consist of placing info into flat files so you can see what is going on).
    Does IE have a problem with data scraping + server-side redirection (I am using response.sendRedirect()) that I don't know about?
    Thanx
    Phil

    Agoston_Bejo wrote:
    The problem is that right after having logged in, while you're still in the filter, the beans managed by JSF haven't been put into any scope yet. (The faces servlet hasn't been called yet, so it hasn't had the chance to instantiate the managed beans, put them into the appropriate scopes etc.) So it is request scoped? Just create one yourself. I however don't see any benefit/reason for having the logged in user in the request scope ..

  • Remote Desktop local printer redirection problem - Server 2012 Foundation

    Hi,
    I am trying to print from Windows Server 2012 Foundation to my local printer hosted on Windows 7.
    When I enable local resources in the RDP client, I can see my printers on the server like redirected. All seems like no problem occured. But only print does not work. ;-)
    I can see the document name in the queue with Error status.
    I tried set up GP with disabling Easy print, the drivers are identical on both machines, event logs are clear.
    The server is freshly installed, running only File server role. No Domain controller role is set. No Terminal Service is set (i think in Foundation is it not possible), only allowed RDP.
    RDP client is the newest. I have not any problem to print from other servers (WS2003, WS2008R2) using this printer. Everytime is the printer automatically redirected to TS*** port and works.
    I spent few hours searching solution with no effect.
    Any idea? Many thanks!

    Hi,
    Did you find any error message during this issue?
    Please check you have enabled necessary port for printer redirection on server side. You can check “Do not allow client print redirection” is disable under GPO setting. Also the user must have enough permission to print the document. Please check below link
    for more information.
    1. Terminal Server and Printer Redirection
    2. Five reasons printer redirection causes Windows printing problems in RDS
    Hope it helps!
    Thanks,
    Dharmesh

  • Server side redirect with 4.5.1 and Netscape Enterprise Server

              Is it possible to have a servlet running under WL 4.5.1 to perform a server
              side redirect ala CGI?
              Here's my config:
              web server: Netscape Enterprise Server 3.6 on solaris, with weblogic
              plugin
              servlet runner: WL 4.5.1 on different host from ES.
              Here's what I want to happen:
              1) HTTP GET from browser to enterprise server
              2) forwarded by plugin to servlet
              3) servlet logs some activity to an application log file, and sends a
              server side redirect to enterprise server
              4) Enterprise server returns the file identified by the rediect directly
              to the client.
              This is possible with enterprise server and CGI, because the ES CGI code
              checks the return stream from the CGI program for "Location: <some url>". If
              it see's that, it tries to locally resolve that URL as the client had asked
              directly for that URL. I think this would only be possible with WL if the WL
              NSAPI plug in supported a server side redirect feature. Anyone know status
              of that? Or might ES support something like this depending on the order of
              the objects in obj.conf?
              Here's what I've tried in the servlet:
              res.setHeader("Location:", location);
              res.setContentType("magnus-internal/redirect");
              res.setStatus(302);
              This just sends an HTTP tempoary new location to the client for a client
              side redirect. Client side redirect is not desirable because it doubles the
              HTTP traffic.
              Another option would be to read the file I want to redirect to from inside
              the servlet and return it from the servlet, but that is not desirable
              because I want to have ES serve the file - thats it's job, it caches, less
              network traffic (between our servers), etc.
              Server side redirect is very useful feature and not that uncommon for web
              applications, so if WL does not support it now, I will probably put in a new
              feature request.
              Thanks for your help
              Mark Johnson.
              

    Why not just use the proxy servlet to redirect to your netscape server? That
              does it on the server side!
              -russell
              Mark Johnson wrote:
              > I belive that sendRedirect performs a client side rediret, not a server
              > side redirect.
              >
              > Guy Tal <[email protected]> wrote in message
              > news:[email protected]...
              > > public void doGet(HttpServletRequest req, HttpServletResponse res) ...
              > > ...
              > > res.sendRedirect("http://destination");
              > > ...
              > >
              > > Guy
              > >
              > > Mark Johnson <[email protected]> wrote:
              > >
              > > > Is it possible to have a servlet running under WL 4.5.1 to perform a
              > server
              > > > side redirect ala CGI?
              > >
              > > > Here's my config:
              > > > web server: Netscape Enterprise Server 3.6 on solaris, with weblogic
              > > > plugin
              > > > servlet runner: WL 4.5.1 on different host from ES.
              > >
              > > > Here's what I want to happen:
              > > > 1) HTTP GET from browser to enterprise server
              > > > 2) forwarded by plugin to servlet
              > > > 3) servlet logs some activity to an application log file, and sends
              > a
              > > > server side redirect to enterprise server
              > > > 4) Enterprise server returns the file identified by the rediect
              > directly
              > > > to the client.
              > >
              > > > This is possible with enterprise server and CGI, because the ES CGI code
              > > > checks the return stream from the CGI program for "Location: <some
              > url>". If
              > > > it see's that, it tries to locally resolve that URL as the client had
              > asked
              > > > directly for that URL. I think this would only be possible with WL if
              > the WL
              > > > NSAPI plug in supported a server side redirect feature. Anyone know
              > status
              > > > of that? Or might ES support something like this depending on the order
              > of
              > > > the objects in obj.conf?
              > >
              > > > Here's what I've tried in the servlet:
              > > > res.setHeader("Location:", location);
              > > > res.setContentType("magnus-internal/redirect");
              > > > res.setStatus(302);
              > >
              > > > This just sends an HTTP tempoary new location to the client for a client
              > > > side redirect. Client side redirect is not desirable because it doubles
              > the
              > > > HTTP traffic.
              > >
              > > > Another option would be to read the file I want to redirect to from
              > inside
              > > > the servlet and return it from the servlet, but that is not desirable
              > > > because I want to have ES serve the file - thats it's job, it caches,
              > less
              > > > network traffic (between our servers), etc.
              > >
              > > > Server side redirect is very useful feature and not that uncommon for
              > web
              > > > applications, so if WL does not support it now, I will probably put in a
              > new
              > > > feature request.
              > >
              > >
              > > > Thanks for your help
              > >
              > > > Mark Johnson.
              > >
              > >
              > >
              > >
              > >
              > >
              > >
              > >
              Russell Castagnaro
              Chief Mentor
              SyncTank Solutions
              http://www.synctank.com
              Earth is the cradle of mankind; one does not remain in the cradle forever
              -Tsiolkovsky
              

  • How to redirect request to a servlet on another server/context

    Hi
    I want to redirect a request came to a servlet to another servlet on another server or atlest different context on same server.
    Thanks in advance,
    --Nagesh                                                                                                                                                                                                                                                                                                                               

    Thanks but, now after rediriceting the request I am
    not getting any ServletInputStream. Getting rintime
    error as NoClassDefinitionFoundError :
    ServletInputStream.That's indicative of a problem with your classpath settings.
    DO I have to do anything the JSP
    (which submitted the request to first servlet) after
    redirecting?Nops, you shouldnt do anything after sendredirect(). The response is committed after using this method.
    ram.

  • Servlets store information on the server side?

    i am working on a tapestry web app.
    is there a way for servlets to store some information on the server side independently. like a http session is visible to only the user who is viewing it, somebody else cannot view somebody elses http session details. but is there a way to share some common information inbetween all user sessions/pages. i dont want to store any info within the db but somewhere within tomcat.
    i hope i am able to express my question properly.

    I am a little confused when you say:
    A user logs onto the server and a new web application is started for him then another user logs on from another place and a new web application is started for that user.
    If they are hitting the same servlet in the same context (directory under your root webapps folder) then there is one web application. Each user is just starting a new session in that one web application. Each user is not creating a new web application.
    That being said, and if it is true (all the users are using the same servlets) then you should use the ServletContext to store data you want to share between users. That is what it is designed for. In Servlets (and JSPs) you can talk about four different scopes where data gets stored in a particular application:
    1) The 'page' scope is relevant only to JSPs, and represents data that is visible only to the current JSP page for the current user. The object used is called PageContext.
    2) The 'request' scope stores data available to all servlets accessed by a single user through a single request (so if forwards, or includes are used to get from one servlet to another). The ServletRequest object is used to store this data.
    3) The 'session' scope stores data available to a single user across multiple requests. The HttpSession object stores this info.
    4) The 'application' scope stores data available to all users across all requests. The ServletContext object stores this info.
    All of the scopes have data stored/retrieved via setAttribute(key,value) and getAttribute(key) methods.
    "cant i maintain a list of users who are generating or viewing a web app from my server at any instance"
    Yes you can. I would use a SessionListener to listen for when new sessions are created. When they are get the information you need and add them to a list in the ServletContext where all users can see it. Then in the SessionListener listen for when a session is destroyed, and remove the user from the list.

  • Handle exception on server side and display a customized jsp error page

    Hi,
    I am developing a java/j2EE web application using servlet, jsp, ejb3 with JBOSS and ECLIPSE.
    Two cases can occur on the server side :
    1) either I have not an expected result in a method and in this case I want to display an error page (a JSP page I suppose) with a personnalized error message
    2) or I have an exception thrown and I want to display the exception message in the former JSP page
    I don't know how to cope with this problem of personnalized error message (or the message of a thrown exception) with a JSP page.
    Does anybody can help me ? Thank you
    Edited by: xflamant on Jun 20, 2009 10:51 AM

    For the case of an unknown Error, simply use a default error page.
    The redirection to this page can be accomplished by inserting folowing code into your web.xml:
         <error-page>
            <exception-type>java.lang.Throwable</exception-type>
            <location>/WEB-INF/jsp/error.jsp</location>       
        </error-page>Known exception can be caught via a try-catch block.
    Then simply dispatch to the page you want displayed an add an attribute containing the error message to the response object.
    This attribute can then be used in the target page to diplay the error.

  • What is the difference between jsp :include and server side include

    what is the difference between jsp :include and server side include(request dispatcher include method)????
    i understand that both request dispatcher include method and jsp:include take dynamic data,so when would one use request dispatcher include and when jsp:include.
    Is the usage interchangeable?i believe jsp include is used only for jsp/html but include directive can be used to include servlets ,jsp and html....correct me if i m wrong and
    do suggest if u hav ny other diff in this context...

    The difference really is: in what format do you want your inclusions? If your environment has many Java developers and only a few designers that focus mainly on, say, Flash, that might push you more towards the server-side include() directive. Or, if you have a large set of pages that receive dynamic content that is displayed in a consistent fashion (such as a workflow header area on a page).
    If, on the other hand, you have more web designers, there may be a greater desire to deal in markup rather than Java code. Java developers themselves might prefer to view markup (JSP) that more resembles the eventual output than something occuring in Java code.
    Finally, there are considerations of tiering. While it is totally possible to (and I have previously) implement 'view classes' that render markup or generate layout templates, JSP's offer, IMO, a subtle, psychological advantage. By forcing a developer to work in a different format, markup versus Java source, the separation on view from controller and model becomes a bit easier. It is still possible to make mistakes, but if a developer at some point notices, "Wait, I'm in a JSP, should I be importing a java.sql class?", then the choice to use JSP includes has paid off in spades.
    - Saish

  • Problem in Server side includes using Tomcat

    Problem in Server side includes using Tomcat:
    I am trying out small programs in servlet.
    I get one example program for server side includes from net.
    The code is:
    <HTML>
    <HEAD><TITLE>Times!</TITLE></HEAD>
    <BODY>
    <P>
    The current time in London is!!! :
    <SERVLET CODE="CurrentTime" codebase="../servlet">
    <PARAM NAME="zone" VALUE="GMT">
    </SERVLET>
    </P>
    </BODY>
    </HTML>
    I placed this test.shtml file in tomcat-home/webapps/ROOT folder and i kept the servlet in WEB-INF/classes folder.
    I renamed the servlets-ssi.jar and i removed the comments for SSI in web.xml file.
    When i run the servlet separately, i am getting the correct result. But if i run shtml file with the URL : http://localhost:8080/Test.shtml,
    i am getting the result as:
    The current time in London is!!! :
    It is not invoking servlet program.
    CAN ANYONE HELP ON THIS!
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • How to set focus in text box at server side

    Hi,
    I have small problem , i have a text box in form , which is get validated at server side in servlet , if it found some thing wrong then it throws exception , i want that when an exception is thrown it should set focus for that perticular text box. so what should i write to perform such a activity.

    Get hold of the element ID in the servlet (and keep the code conventions) and print it out to some Javascript function which does a focus during the onload.
    There's an example of focus/highlight using JSP/Servlet/Javascript in this article: [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html]. Also see the screenshots at the very bottom.

  • Server Side Includes with .irpt pages

    I am intrested in using server side includes within my .irpt pages for example
    <!#INCLUDE FILE="file.inc">
    specifically inside of my applet tags to reference a standard set of parameters that I would like to be passed into my display templates.  Does xMII have a similar representation of server side includes for .irpt pages?

    It might make your head explode, but in a good way...
    Also, you'll need 11.5 or newer to run this. There are so incredibly many opportunities that this might open up for you to deliver not only static, but also dynamic embedded server-side content.
    There are many aspects of xMII that are largely untapped.  A few common ones are the ability of the Runner servlet (which invokes xMII BLS transactions) to stream virtually any type of content back to the requestor (XML, HTML, text, images, PDFs, Excel, whatever).
    The other feature that not too many people use is the ability to use an xMII BLS transaction as a "stylesheet".
    Lastly, there is the little-known "<SERVLET>" tag that can be used in IRPT pages.
    Put all these pieces together, and amazing things can be done.  The example I'm going to show you uses a BLS transaction, but it can also be done with an XSL stylesheet (if the desired included HTML is static).  But let's go for the cool approach...
    Let's assume you have some "stuff", such HTML page content, that you want included in a specific position on your web page.  Let's also assume that this "stuff" resides in a file accessible at http://localhost/MyInclude.html (the file extension doesn't really matter).
    Create a new BLS transaction with no inputs and an output of type String (the name of the output doesn't matter - but in our case, let's assume you name it HTMLOutput).  To workaround a cosmetic bug (which will be fixed in a future patch), you should also create a second output (doesn't matter what name or type) - so add one called "DummyOutput" of type String.  Not worth explaining why - just do it. 
    Next, add either a TextLoader or HTMLLoader action (in the Web group) to your transaction (they both do the same thing, actually - just different icons).  In the Output links tab, assign the StringContent of the loader action to the transaction output.  This basically accomplishes the loading and streaming of your included "stuff".
    Save this transaction.  Let's save it in a folder called CoolStuff, with the name IncludeTest.
    In your IRPT page, add the following code where you want the "stuff" to appear.
      <SERVLET NAME="Illuminator">
           <param name="Stylesheet" value="xacute://CoolStuff/IncludeTest" />
         <param name="OutputParameter" value="HTMLOutput" />
         <param name="Output-Content-Type" value="text/html" />
         <param name="Content-Type" value="text/html" />
      </SERVLET>
    Save the IRPT page, load it, and you're in business!
    You can probably already start to envision to possibilities for adding more sophisticated business logic to create "dynamically" embedded content in your IRPT pages...
    Best regards,
    Rick

  • Server-Side Includes in weblogic server 5.1

              Hi,
              I tried Server-Side Includes examples in weblogic server 5.1 thru .shtml file.
              I am able to load the .shtml file but its not loading the included servlet. But
              I am able to load the included servlet alone separately.
              Somebody can be assist me what I have to do?
              I am using WebApplication WAR structure for my application.
              ex: http://localhost:7001/esp/hellooWorld -- loading the servlet
              http://localhost:7001/esp/html/ServletInclude.shtml -- not loading servlet
              where 'esp' name of the WebApplication
              The .shtml file code is given below
              <html>
              <body>
              <servlet name=hellooWorld>
              </servlet>
              </body>
              </html>
              Looking forward for some help
              Thanks
              

              Your WebLogic doesn't know it's supposed to be doing server-side includes. Make
              sure you have .shtml registered/enabled - see the docs.
              Mike
              "Jyothi" <[email protected]> wrote:
              >
              >Hi Mike,
              >Thanks for your reply.
              >>What errors (if any) do you see in the log file?
              >Just coming up with blank screen. No errors reported in log file. Nothing
              >coming
              >in log file regarding the servlet.
              >>
              >>When you display the page in a browser, what does View -> Source show?
              >Just getting blank screen. If I see view source same source code coming
              >up. Here
              >is the view source when I view it from browser
              >**********************************************
              ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
              ><html>
              ><head>
              ><title>Including a servlet with SSI</title>
              ></head>
              >
              ><body
              > bgcolor="#FFFFFF"
              > link=#DB1260
              > vlink=#828282>
              >
              ><font face="Helvetica">
              >
              >
              ><p>
              ><servlet name=hellooWorld>
              ></servlet>
              >
              ></font>
              ></body>
              ></html>
              >*********************************************************
              >>Did you register the servlet?
              >Yes. I registered the servlet. Thats why if I load the servlet alone
              >I am getting
              >the output.
              >http://localhost:7001/esp/hellooWorld -> url used to load servlet alone
              >>
              >I hope this info helps to you to analyze my problem
              >
              >Thanks
              >Jyothi
              >>
              >>"Jyothi" <[email protected]> wrote:
              >>>
              >>>Hi,
              >>>I tried Server-Side Includes examples in weblogic server 5.1 thru .shtml
              >>>file.
              >>>I am able to load the .shtml file but its not loading the included
              >servlet.
              >>>But
              >>>I am able to load the included servlet alone separately.
              >>>Somebody can be assist me what I have to do?
              >>>I am using WebApplication WAR structure for my application.
              >>>ex: http://localhost:7001/esp/hellooWorld -- loading the servlet
              >>>http://localhost:7001/esp/html/ServletInclude.shtml -- not loading
              >servlet
              >>>
              >>>where 'esp' name of the WebApplication
              >>>
              >>>The .shtml file code is given below
              >>>-----------------------------------
              >>><html>
              >>><body>
              >>><servlet name=hellooWorld>
              >>></servlet>
              >>></body>
              >>></html>
              >>>--------------------------------------------------
              >>>
              >>>Looking forward for some help
              >>>
              >>>Thanks
              >>>
              >>>
              >>>
              >>>
              >>>
              >>
              >
              

  • Running server side methods prior to applet launch

    Hi all,
    I have recently become involved in the JSP world. My question is this:
    How can I get a server-side process to run prior to the launcing/running of an applet that must also be present on the page? Is there a way to force an order of execution within a JSP?
    Due to the nature of the code, it is impossible for me to create a secondary page that runs the server side process prior to being redirected to a page containing the applet.
    Any thoughts?
    Thanks from a newbie!
    --Speed Racer                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey there,
    Yes, it did help, however, I realized that a redirection of the action to another URL (jsp) instead of the assigned action class would allow me to manage the auditing I needed to do.
    Thanks for the response!
    --Speed Racer                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

  • Servlet in client/server application?

    hi,
    I am planing to make a client server application( SWING & an OODB), would it be clever to use servlet ( not httpservlet) as midle tier framework?
    If yes , what are the benefits?
    Thanks.

    thanks for responding
    actually my client don't wanna run a separate server application on the hosting machine as it costs too much, so thats why i think there is no other way to achieve the task rather than using servlets.
    please do help me or atleast give me a suggestion. actually i'm developing an internet messenger application. i have developed it using client/server application model in which both (the swing client and the server) uses java sockets to communicate with each other. but now i want to develop the server side of the messenger as servlets. but as far as i know the servlets follow the request/response model. if i follow that model i have to use some sort of client pull after certain amount of time say after five or ten seconds, and this approach does not fulfill my requirements as it would slow the performance if there are hundreds of clients calling the servlet every 5 seconds. thus i want to create persisted connections between the client and the servlet which last for the life time of the user's session. also it is important for the data integrity of the application, so please help me in this matter as i have no other source of guidence in this meany world. i hope you will certainely help me in this matter. please mention that if there are any drawbacks of my approach i mean the persisted connections.
    thanks you a lot
    Best reagrds
    Imran Sarwar.

Maybe you are looking for