Is this possible??? servlet to servlet?

Is it possible for one servlet to make some sort of call to another servlet and recieve information back without losing "control"? For example, you start Servlet A and you send it a username and password. Servlet A then calls Servlet B, and sends Servlet B the same username and password. Servlet A should then receive some information back from Servlet B and then Servlet A continues processing. (please don't get stuck as to why I don't send servlet B the username and password and do everything in one servlet.)
Is this situation possible? If it is can someone point me in a direction on how to do this? Preferably with some example code if it's available.
I'd really appreciate some help on this.
Thanks,
James

I actually had to solve this problem. There are other servlets running within the same container/process as my own who's code I didn't have access to. My first attempt was to call the other servlet(s) via the URLConnection class, however, this option presents some complications when https is employed. It does so especially when using an unsigned certificate for testing. Below is the code I used to call a servlet within the same container process and a servlet to serve as an example of how to use it.
***** ServletCaller.java ***********
import java.lang.reflect.Method;
import javax.servlet.http.*;
import javax.servlet.*;
public class ServletCaller
     public static void callServlet( String servletName,                     ServletConfig config, HttpServletRequest req,                     HttpServletResponse resp ) throws Exception
          Class [] doGetArgTypes =                                    {HttpServletRequest.class,
               HttpServletResponse.class};
          Class [] initArgType = {ServletConfig.class};
          Object [] doGetArgs = {req,resp};
          Object [] initArg = {config};
          Class clz = Class.forName(servletName);
          Object servlet = clz.newInstance();
          Method initMethod = clz.getMethod("init",initArgType);
          Method doGetMethod = clz.getMethod                              ("doGet",doGetArgTypes);
          initMethod.invoke(servlet,initArg);
          doGetMethod.invoke(servlet,doGetArgs);
******* TestServlet.java ***********
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import CustomRequest; // Extends HttpServletRequest
import CustomResponse; // Extends HttpServletResponse
import ServletCaller;
public class TestServlet extends HttpServlet
     protected void doGet(HttpServletRequest req,                          HttpServletResponse resp)
          throws ServletException, IOException
     {try{
          CustomRequest r = new CustomRequest(req);
          CustomResponse rp = new CustomResponse();
          r.setQueryString("ARG1=VALUE1&ARG2=VALUE2&"
               +"ARG3=&ARG4=VALUE4");
          ServletCaller.callServlet("SnoopServlet",
               this.getServletConfig(),r,rp);
          // Get response from CustomResponse object
          String s = rp.getOutput();
          resp.setContentType("text/html");
          resp.getOutputStream().println(s);
     }catch(Exception e){throw new IOException(e.getMessage());}
The CustomRequest and CustomResponse class definitions are HUGE, but were relatively easy to build. If you're having trouble building them I can post them too.
Hope this helps.
--Kurt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • HELP! JSP as items in a region - is this possible?

    Hi All,
    Can someone please tell me how to bring in a JSP code as an item or portlet within a region. Is this possible with Oracle9iAS release 2? I need to generate dynamic html within a particular region based on a query string parameter and I thought this is one way of doing it.
    If anyone can help, that would be great!
    Thanks in advance,
    Kim

    Kim,
    There are many articles on Portal Center that discuss building portlets from JSPs. You can also post questions on this topic to the PDK forum.
    For PL/SQL, there are a number of options. You can build PL/SQL portlets - the dynamic page component is a good start, that is conceptually similar to JSPs.
    You can also create PL/SQL items that can be rendered in-place or displayed as a link - make sure that you don't use the "Simple PL/SQL" item type, as you can't control the rendering behaviour. Use the supplied "PL/SQL" item type, or create your own custom item type based on "Simple PL/SQL".
    Finally, any item type (except the "simple" ones) can be associated with a procedure that can generate dynamic content. The procedures can be PL/SQL or any function that can be invoked via a URL (e.g. a JSP or servlet).
    Note that in your PL/SQL procedures you'll need to use the HTP package to generate HTML.
    Regards,
    Jerry
    Portal PM

  • I have two separate itune accounts under two different email accounts and would like to combine them under one account.  Is this possible and if so, how do I do it?

    I have two separate itune accounts under two different email accounts and would like to combine them under one account.  Is this possible and if so, how do I do it?

    If you go to Settings > iTunes & AppStore , you can sign out from your account, and sign in with the one you've used to purchase apps.This will not remove any apps you already have on it.
    Then you can go to AppStore and download apps you've purchased (either via "Purchased" button in "Updates", or simply search for them and download them.
    That way you can have multiple accounts' apps on your iPad. When updating, you will be prompted for the credentials for account you've purchased given App with.

  • I work with a child who is not able to move his neck.  to see the ipad, it has to be placed high above the table (eye level).  he needs access with a mouse - is this possible?

    I work with a child who has physical disability and cannot move his neck.  The ipad needs to be eyelevel in order for him to see it, but he also is not able to raise his hand and would need mouse access...  is this possible?

    I'm sorry but the iPad does not work with a mouse, there is no cursor on the iPad and the iPad was designed as a touch screen device so a mouse will not work.
    I really don't know what to suggest other than this new device, and it might be worth a look. I assume that the child can use his hands for a keyboard.
    http://www.thinkgeek.com/product/e722/

  • Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?

    If you just installed iCloud does that mean you updated the iOS that's running on your iPad?  If so, you'll want to restore all the programs you have from the backup you hopefully made.
    Refer to these articles for help.
    iTunes: Backing up, updating, and restoring iOS software.
    If you don't want to use iCloud, simply don't activate it.
    You can also download the programs again.
    If you live in a country that supports re-downloading apps then you can re-download them.  You can refer to this article for more help.
    Downloading past purchases from the App Store and iTunes Store
    What to know if your country supports downloading past purchases?
    iTunes in the Cloud Availability

  • I am getting old and looking forward to use I Pad as a Phone if possible through WIFI! I this possible? The screen is to small for me! If possible, with new I Watch taking calls, other uses through I Pad!

    Like I wrote on title, I am getting old and it is not easy to see E-mails, news etc. on a I phone! New I phone will not help me for the size.
    If possible, everything without calls, I would like to use I Pad as direct unit, and for calls through I Pad over WIFI all calls. If a call as Skype, I would like
    to use the I Pad as a monitor. Is this possible?
    I found on a side that there is a product for people for better hearing, which can be put into the ears, using WIFI with I Phone.
    If this product could be used also for I Pad as a Phone for hearing, and the I watch or I Pad as Microphone, it will be great for old Mac users.
    Is this possible with our system know?
    I am using Mac since Classic II! Would like to continue with the newest items with the possibility for old person with bad Eyes or Ears.
    Looking forward for a kind answer
    with regards
    Christian an old Mac user!

    Definitely No

  • I have a Macbook Pro with OS 10.6.8 with no updates. Bundled is iPhoto 11, version 9.2.6. I would like to update my OS to 10.9.5 or later. Is this possible and which version is recommended?

    I have a MacBookPro with OS 10.6.8. It has no updates. This version contains Iphoto 11, version 9.2.3. I would like to upgrade my operating system to 10.9.5 or later. Is this possible and how best to proceed? How will this affect iPhoto?
    Thanks, Jeff

    If you have a mid/late 2007 MBP you can install the latest OSX that is available, on your MBP.  Mavericks (10.9) has been replaced by Yosemite (10.10) and is no longer available in the App store. 
    You choices are Lion (10.7), Mt.Lion (01.8) (both $20) or Yosemite (free).  The first two are available from the Apple online web site.  Yosemite can be downloaded from the App store.
    Ciao.

  • I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    I just bought my macbook pro and it's charged up to 100% and is still plugged in but now shows the battery at 98%.  How is this possible when it's plugged in to the charger and the green light is on?

    The system regularly lets the battery drop to about 95% when on the charger, then recharges to 100%.  This lets the batery exercise "just a little" all of the time and saves the recharge curcuits from overuse.
    Regualr occurence for me.
    Also ... you need to let your battery work at least once per month.  Let it run down to 40%, but not less if you can at all avoid it.  Running thr battery fully dead will shorten the battery life significantly.

  • Using one ipod on 2 computers - is this possible?!

    Hi guys I would really appreciate it if somebody could help out with this:
    I want to buy my girlfriend an 80gb Ipod Classic for xmas and load it with some music using my existing version of itunes (version 7.3.2.6) and then give it to her so that she can use the ipod with the verison of itunes that it comes with or she downloads. *This music will NOT be music purchased from itunes.*
    Is this possible? When her friend connects her new nano to my girlfriends pc and tries to use my girlfriends slightly older version of itunes all of the songs are greyed out and not useable.
    I do not want to buy the ipod and load it up only to find she can then not use it with her version of itunes.
    If anyone is certain about this i'd be greatly appreciative of an answer.
    David

    To change it back to automatically syncing you remove the check mark from "Manually manage songs and videos" and press Apply. If you don't want to use it as file storage device and want it to automatically eject when it is finished updating you also remove the check mark from "enable disk use" (this is checked by default when you set the iPod to update manually. Remember though that if you go back to updating automatically, any songs on the iPod that aren't in iTunes will be removed. You can't "sync" that is automatically update an iPod from multiple libraries or computers: Loading songs onto iPod automatically - Windows

  • How do I connect  Apple 20" Cinema Display to orignal MacBook Air which does not have a Fire-Wire port. Is this possible? Any advice would be appreciated. I have the Micro-DVI to DVI adapter. Norm

    I Wish to connect my 6 year old Apple 20" Cinema Display to an orignal MacBook Air which does not have a Fire-Wire port. Is this possible? Any advice would be appreciated. I have the Micro-DVI to DVI adapter. Norm

    The FireWire cable is just for the FireWire ports on the display.  The display will run without it.

  • I want to buy a Ipod Nano 16gb and it says it holds up to 4,000 songs, and 16 hours of video but on my Itunes I have 2,593 songs and it says I have 19.88 gb. How is this possible?

    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?

    Daniella04 wrote:
    I want to buy a Ipod Nano 16gb that says it holds up to 4,000 songs, 16 hours of video, and 14,000 pictures. On my Itunes Library, I have 2,593 songs and it says I have 19.88 gb just of songs. How is this possible? If I buy the Nano, will I not be able to have all my songs on the ipod? The music is my first and only prioarity. I want to be able to have up to at least 3,000 songs, even if that means not having video or pictures. Can someone please help me?
    Daniella,
    The estimated song capacities, such as 4000 songs in 16 GB, are based on 4 minute songs of 4 MB each, which is what you get at 128 encoding. 
    Most of us nowadays use well above 128.  (For example, the iTunes Store and Amazon MP3 both sell songs only in 256.)
    However, you can still make more songs fit!  When you sync your iPod, use the option to "convert higher bit rate songs," as pictured.  Choose 128.  This fits more on the iPod, but does not change the songs in your library.

  • I would like to access both my iTunes and my husbands iTunes on the same computer.  However, we still want our separate logins for our devices (iPad, 2 iPhones) for purchases.  Is this possible?

    Is there a way to have one computer hold both my iTunes account and my husbands iTunes account at the same time.  We do not want to log in and out, but want to be able to access both purchases on the same computer (songs, movies, etc).  However, we want to keep our accounts seperate for purchases on our devices.  Is this possible?

    How to use multiple iPods, iPads, or iPhones with one computer

  • There is no space to store video on my computer.  I am am looking at getting 1 terabyte on the cloud in hope i can edit video off of the cloud the same way I can with a hard drive.  Is this possible?

    There is no space to store video on my computer.  I am am looking at getting 1 terabyte on the cloud in hope i can edit video off of the cloud the same way I can with a hard drive.  Is this possible?

    Buy another hard drive.  They're cheap these days.
    In fact, buy a couple of 'em.  I recommend a minimum of five internal hard drives.
    C: Windows and Programs
    D: Project, graphic and audio files
    E: Cache and Scratch
    F: Media
    G: Export

  • HT204053 I have 4 iphones on the same Apple ID, but would like 4 different accounts and iCloud is this possible?

    I have 4 iphones on the same Apple ID, but would like 4 different accounts and iCloud is this possible?

    Create a new Apple ID for the one you want to change.

  • In contacts section for the groups section i want to delete old groups i have on the phone and then add a new group for easy access for work contacts for calling. rather then searching each individual contact when needed. is this possible?

    i currently have about 6 different groups listed on the iphone in my contact list section and i want to delete the old ones and create a new group for work puposes!
    i dont want any apps all i want is something similar to my favourites list but in a group so i can just go into that work group and scroll to the person i need to call and this way seperating my personal and work contacts.
    because i do alot of calls from my car i dont want to have to search my contact lists to find the right person i just want them all in a simple folder.
    is this possible because if i already have groups on my iphone i should be able to delete the old ones and create a new one?

    Deleting groups on the phone and creating new ones is not supported with iOS4, you'll have to do that on your computer and sync again.
    Let's see if they changed that in iOS5 when it is released.

  • I want to delete my mobile me account not just from my iPhone but from existence. I want to delete it so that no emails can be received to it, and the sender would receive an undeliverable message. Is this possible?

    I want to delete my mobile me account not just from my iPhone but from existence. I want to delete it so that no emails can be received to it, and the sender would receive an undeliverable message. Is this possible?

    No, you can stop using the account, but you cannot delete it.

Maybe you are looking for

  • Problem in summation on a column with possible null values

    Hi, I want to do summation on a column. If I use <?sum(amount)?>, if there is any null value,its giving NaN as output. From the forum I got the below syntax <?sum(AMOUNT[number(.)!='NaN'])?> but it is also not giving me the expected result. Its alway

  • IPhoto won't quit! Empty trash with 8000 +....

    Cleaned up iPhoto, deleting, now have 8000+ images in iPhoto trash. Click iPhoto Trash>Empty Trash, and separate upper right "Empty Trash" button... neither one will dump all these photos.... And the program freezes with swirling after the box shows

  • Officejet 6110 shared network from a Netgear Ready NAS unit

    Dear HP Team & HP friends, I bought a ReadyNAS unit from Netgear. Their compatibility list says the Officejet 5000 and 7000 series work with this unit. Do I believe the 6000 serie also. And it does as when I plug it it comes up as a shared printer fo

  • How to edit to a table.

    Hi All, I am trying to create a table with inputfield columns. So, i want the user to input data in this table. I want to bind this columns with a node context of a BAPI and to save this data. The procedure i did is: From the Standart Complex i choos

  • Is there a way to get scratches off the back off my ipod?

    My ipod has some scratches on the back and i was wondering if there was a way to get them off.