Palin old java class Servlet Communication issue

I am sending data to servlet and able to get back data to plain old java class using url.openConnection mechanism.But I want to redirect another jsp page after servlet get data from java calss.
Can any one help me please
Regards
Madhu

What alternative could there be?
You're calling a webserver which just happens to be running a Java process to generate its output.
You don't have to know that, that's the whole point in using servlets...
So no, there's no way (and if there is it's a terrible breach in the security of your server).

Similar Messages

  • Accessing ServletContext from Java class Data Control

    I'm writing some business service classes as plain old java classes that will be bound to a JSP using ADF and STRUTS. The business logic requires the real path of the servlet context to access a file. How do I call servletContext.getRealPath("/WEB-INF/test.xml")?
    I know this is mixing web tier code into model code, but I don't know any other way to do this.
    Thanks in advance...

    Ok, it looks like I'll have to define my own action class and pass the pathname on to the data control class.

  • How to hot deploy java class?

    I write some java class and put them into the weblogic\class folder to
    replace the old java class files.
    When I run the program, the server still run the old java class.
    But when I restart the server, the server runs new java class.
    The server must restart, when I want to run new java class?
    thanks

    Does this work ??
    I was unable to achieve hot deployment using REDEPLOY file.
    Sheng Sheen <[email protected]> wrote in message
    news:[email protected]..
    You need to create a REDEPLOY file and touch the file.
    From the documentations:
    Dynamic Redeployment of Exploded Applications
    You can also dynamically redeploy applications or application components
    that have been deployed in exploded format. When an application has been
    deployed in exploded format, the Administration Server periodically looks
    for a file named REDEPLOY in the exploded application directory. If the
    timestamp on this file changes, the Administration Server redeploys the
    exploded directory.
    If you want to update files in an exploded application directory, do the
    following:
    a.. When you first deploy the exploded application, create an empty file
    named REDEPLOY in the directory where the exploded application resides.
    b.. To update the exploded application, copy the updated files over the
    existing files in that directory.
    c.. After copying the new files, touch the REDEPLOY file in the exploded
    directory to alter its timestamp.
    When the Administration Server detects the changed timestamp, it redeploys
    the contents of the exploded directory.
    "Alex" <[email protected]> wrote in message
    news:[email protected]..
    I write some java class and put them into the weblogic\class folder to
    replace the old java class files.
    When I run the program, the server still run the old java class.
    But when I restart the server, the server runs new java class.
    The server must restart, when I want to run new java class?
    thanks

  • Communication between 2 servlets/java classes.

    Hi,
    I’ve a problem. Not sure if it’s a simple one.
    I have a web app with servlets (say Servlet1, Servlet2, etc.) in it. I use a SQL query in Servlet1 and fetch an employee’s information (say empinfo) from the database. This is a string value. Now, I need to pass this “empinfo” to Servlet2.
    I might sound dumb till here but please continue till the end to know what I still have to say…
    1.     I tried using getters and setters. Servlet2 has the “empinfo” value I need. This is the first time Servlet2 is accessed.
    2.     But, think that Servlet1 is transferring the control to an html page. And, this html page submits its parameters (say manager) to Servlet2. And, when this html passes its control to Servlet2, the “empinfo” value I need is gone because I used “empinfo” as a class member/global.
    3.     So, when the control enters the Servlet2 the second time everything is lost and this is when I need the “empinfo” value.
    4.     I cannot make the “empinfo” value in Servlet2 “static” because it keeps changing.
    Note: I tried with all these: httpsession, reflection, etc. but nothing seems to fulfill my task.
    Actually, Servlet2 lets the users to download the “empinfo” when a link on the html page (which sends the parameters to this servlet) is clicked.
    I used httpsession to store this “empinfo” in Servlet1 and used to grab the value in Servlet2.
    Then, I ran this app on my localhost. Then:
    Step1: I opened up one browser and when I clicked the link on html, I checked the “empinfo” value. It was fine.
    Step2: I opened up another browser and when clicked the link on html, I checked the “empinfo” value. It worked again.
    Step3: Now, I went back to the html page in the browser1 and clicked the link and checked to see the “empinfo” value and now it has the value of that in browser2.
    The “empinfo” always had the latest value. Previous values are overwritten.
    If I could find a way to cache the Servlet1 object to use it in Servlet2 then I think my job is half done because even if I let Servlet2 keep a reference of the Servlet1, the html page is ruining the desired result.
    If anyone can let me know how to do this with normal Java classes even that works for me.
    Thanks in advance.

    Thanks for the reply.
    Actually, when I used the session the IE browser behaved properly and its the FireFox that was weird.
    I think this is because Firefox uses single cookie for many instances of itself.
    Thanks again.

  • Standard Java class communicating with a servlet

    Hey,
    I am trying to access a standard java classes member via a servlet class however the data is never received even though the member is visible on compilation. is there something Im doing wrong ?
    public class Start {
    //lots of stuff
         static List<Plug> plugList = Collections.synchronizedList(new LinkedList<Plug>());
    //lots more stuff
    public class wah extends HttpServlet{
            public void doGet( HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
                    doPost(request, response);
        public void doPost(HttpServletRequest request,
                                    HttpServletResponse res)throws ServletException, IOException{
                    res.setContentType("text/html");
                    PrintWriter out = res.getWriter();
                    out.println("wahwahwah");
                    synchronized(Start.plugList){
                            out.println("pluglist");
                            Iterator i1 = Start.plugList.iterator();
                            while (i1.hasNext()) {
                                    Plug oldPlug = (Plug)i1.next();
                                    out.println("PLug : " + oldPlug.getaddress64());
            }//doPost
    }

    Don't post all your code. Instead, make a simplified version of the code that demonstrates what your problem is and that we could compile and see what is going on. Make it as simple as possible but still demonstrating the problem.
    Who knows, when you make the SSCCP (small, self contained, compileable program) you will find your mistake as well.
    But without seeing any code all I can say is that the date you are accessing in the list has not been made available when you try to get it from the servlet. Perhaps the servlet call is blocking the other threads from accessing the list to put data into it, perhaps the other threads haven't begun working yet, perhaps the list you give to the servlet isn't the same list (but instead a copy of the list) that the data is being entered into, or many other reasons.
    One thing I would assume you need to do, since the Servlet is the data consumer, you need to make sure the data has been entered before the servlet tries to read it. The best way to do that is to put a wait() in the servlet code so that it knows it can't do anything until the producers are finished. Then the producers would add a notify() to tell the servlet to go ahead and display the data.
    So some modification might be:
    public class Start {
    //lots of stuff
         static List<Plug> plugList = Collections.synchronizedList(new LinkedList<Plug>());
            //marker to let servlet know that it can consume data
            private static boolean done = false;
            //producers call this method when list is ready for use
            static void setReadyToConsume() { done = true; }
            //servlet calls this to check if the list is ready
            public static boolean isReadyToConsume() { return done; }
    //lots more stuff
        public void doPost(HttpServletRequest request,
                                    HttpServletResponse res)throws ServletException, IOException{
                    res.setContentType("text/html");
                    PrintWriter out = res.getWriter();
                    out.println("wahwahwah");
                    synchronized(Start.plugList){
                           //Hold off trying to use list until list is ready
                            while (!Start.isReadyToConsume()) {
                                  try {
                                          Start.plugList.wait();
                                  } catch (InterruptedException ie) {
                                          log("Waiting for Plugs to be ready interrupted.  Continuing to wait.");
                                          log(ie.getMessage(), ie);
                            out.println("pluglist");
                            Iterator i1 = Start.plugList.iterator();
                            while (i1.hasNext()) {
                                    Plug oldPlug = (Plug)i1.next();
                                    out.println("PLug : " + oldPlug.getaddress64());
            }//doPostAnd don't forget to add a Start.plugList.notify() or Start.plugList().notifyAll() in the producer code after it calls the setReadyToConsume() method.

  • InterMedia Java Classes for Servlets and JSPs and Netscape

    I am using the interMedia Java Classes for Servlets and JSPs to upload and retrieve multimedia data. I have found that it is much more performant in Internet Explorer (5.5) than in Netscape Communicator (4.7). In fact, I cannot upload images larger than 10K at all using netscape. However, the same image can be uploaded into the same application using IE. Is this a known issue?
    Thanks in advance.

    Hi,
    We have successfully uploaded multimedia data in the giga-byte range (Quicktime and AVI files) at the same speed with both the Netscape (4.7n) and MS IE (4.n and 5.n) browsers. One thing we have noticed is that its very important to set the manual proxy settings correctly if you have an environment with a proxy server. If you don't, then uploads can go via the proxy server and, for some reason, that seems to take considerably longer. For example, suppose you are in the www.xyzco.com domain and are connecting to a host named webserver.www.xyzco.com, then specify webserver and webserver.www.xyzco.com (to cover both cases) in the "Do not use proxy servers for..." box in the manual proxy server configuration screen. Also, if you're using a tool such as JDeveloper that uses the host IP address in the debugger environment, then you also need to add the numeric-based (nnn.nnn.nnn.nnn) IP address to this list.
    Hope this helps.
    In order to better understand the variety of ways in which our customers are using interMedia, we'd be very interested in knowing a little more about your application, the interMedia functionality that you are using, and how you are developing and deploying your application. If you are able to help us, please send a short email message with some information about your application, together with any comments you may have, to the Oracle interMedia Product Manager, Joe Mauro, at [email protected] Thank you!
    Regards,
    Simon
    null

  • How to convert old Java Servlets to OSGi "Servlet" Bundles

    Hello I'm looking for some help/insight on the best way to convert some of our old Java Servlet code into new OSGi Bundles that can be accessed as servlets.  I'd like to be able to install the new bundles then access them on one of our CQ instance using something like "/servlet/servlet_name".
    So far I've been able to create a new bundle, and install it into CQ but I haven't been able to access the bundle at the servlet mapping URL that I would expect.  So far what I've found online has lead me to believe that I need to use the Felix Annotations to describe my servlet.
    @Component(immediate = true, metatype = true, label = "Servlet Name")
    @Service
    @Properties({
        @Property(name = Constants.SERVICE_DESCRIPTION, value = "Servlet Name"),
        @Property(name = "sling.servlet.methods", value={"GET"}),
        @Property(name = "sling.servlet.paths", value = "/servlet/my_servlet_mapping"),
        @Property(name = Constants.SERVICE_VENDOR, value = "VendorName")
    public class TellAFriend extends HttpServlet {...
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
    Once I have this installed, and running without an error in the logs for CQ I tried to go on my local instance to http://localhost:4502/servlet/my_servlet_mapping but I only get 404 Resource Not Found errors.  I've even gone to the Sling Resource Resolver and it doesn't resolve to anything either.
    Is there more than the Servlet Information need into the Annotations to convert "old" code into a new OSGi Servlet Mapped Bundle?

    I must be missing something else configuration wise since I created a new Servlet basically using the code you provided above.  I deployed it as part of the bundle that I'm trying to create.
    The bundle installs and stars fine but I still can't access the servlet.  Are there CRXDE based configurations that are requried too to configure Servlets. 
    Here's my test servlet file.  I tried going to http://localhost:4502/servlet/TestCQServlet and just get the same 404 error I'm getting for the other 2 Servlets Java classes in my Bundle.
    import java.io.IOException;
    import javax.servlet.ServletException;
    import org.apache.felix.scr.annotations.sling.SlingServlet;
    import org.apache.sling.api.SlingHttpServletRequest;
    import org.apache.sling.api.SlingHttpServletResponse;
    import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
    @SlingServlet(paths = "/servlet/TestCQServlet", methods = "GET")
    public class TestCQServlet extends SlingSafeMethodsServlet {
        // @Reference
        // private Repository repository;
        private static final long serialVersionUID = 6239754936223276983L;
        @Override
        protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
            response.setHeader("Content-Type", "application/json");
            response.getWriter().print("whatever");

  • Issue with Java Class based DataControls.

    Hi,
    I'm actually working with JDev 11.1.1.3.0.
    And we got a requirement to build a search page which should create a dynamic query. And we are not using ADF BC in this project.
    Instead, writing some ServiceDelegates(Java Classes) which internally calls EJB services to do CRUD operations.
    Finally, created DataControls using these Service Delegates to design UI.
    Now one thing is clear that .... we are using java class based service delegates.
    *Issues
    =======
    1. I have a table with 4 columns, in which 2 columns are of type selectOneChoice.
    2. Now, based on first selectOneChoice selection ... second selectOneChoice should display corresponding values. It is something like this. First select one choice contains all KEYS. Based on the KEY selection second select OneChoice should display VALUES corresponding to the KEY.
    3. I have around 20 KEYS in the first selectOneChoice.
    4. User can add rows to the table as many as they want.
    5. For each row, the first selectOneChoice is same(contains same keys).
    The issue is, For the first time(when user logs into the screen ....) the table will be displayed with one row which contains 2 selectOnechoices and 2 inputText boxes and a ADD button at the end of each row.
    1. User selected a KEY from first selectOneChoice. Hence, second selectOneChoice populates values corressponding to KEY. And user clicked on ADD button.
    2. Now the first row was like that only. And a new Row got added to the table.
    3. In the second row ... Now user selected a different KEY in first selectOneChoice. And the second selctOneChoice displayed values corresponding to KEY selected.
    4. This is also fine. But now, when user tried to click on ADD button to add THIRD ROW ... the table got added with a new row.
    5. Here is the problem.... From here onwards, whenever any new row get added to the table ... the first row's second selectOneChoice values are setting with values of second row's secondSelectOneChoice.
    6. Finally ... what i'm trying to do is, the second selectOneChoice should not get affected/refreshed because of adding a new row.
    If it is not clear ... please share your email address. I can share the sample code with you.
    This is an high priority task given to me.
    Please let me know your comments ASAP.
    Thanks & Regards,
    Kiran Konjeti

    You could try the following to see where the class was loaded from.
    System.out.println(ResourcesAndRatesForm.class.getProtectionDomain().getCodeSource());

  • Calling a servlet in java class

    Hello,
    I try to call a servlet from java class
    but is dose not work
    what should be the problem
       public void callServlet()
              try
                            // xxservlet is the servlet name
                   URL url = new URL("http://www.mydomain.com/xxservlet");
                   URLConnection hpCon = url.openConnection();
                   hpCon.setDoOutput(true);
                   OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
                   out.write("This Is a Test");
                   out.flush();
                   out.close();
              }catch(Exception ex){ex.printStackTrace();}     
    // My Servlet  is in package servlets
    public class XXServlet extends HttpServlet
        public void service(HttpServletRequest req, HttpServletResponse resp) {
            try {
                 ServletInputStream sin = req.getInputStream();
                 int len = req.getContentLength();
                    byte[] input = new byte[len];
                    ServletInputStream sin = req.getInputStream();
                   int c, count = 0 ;
                   while ((c = sin.read(input, count, input.length-count)) != -1) {
                       count +=c;
                  sin.close();
                  String inString = new String(input);
                  System.out.println("Servlet is running ...."+inString);
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    // web.xml
    <servlet>
           <servlet-name>xxservlet</servlet-name>
           <servlet-class>servlets.XXServlet</servlet-class>
        </servlet>
       <servlet-mapping>
        <servlet-name>xxservlet</servlet-name>
        <url-pattern>/xxservlet</url-pattern>
      </servlet-mapping>
    }regards
    Edited by: the_Orient on Mar 30, 2009 3:16 AM

    I have start servlet from brwoser only to test that servlet works fine
    A gain what I need
    I want to call a servlet from a javs class
    URL url = new URL("http://www.mydomain.com/myservlet");
      URLConnection hpCon = url.openConnection();
      hpCon.setDoOutput(true);
      OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
      out.write("Hello Woprld");
      out.flush();
      out.close();// Servlet
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
            try {
                  String xp =req.getSession().getServletContext().getRealPath("/");
                  File f = new File(xp+"/students/info.txt");
                  f.createNewFile();
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    problem file can not be created
        public void doPost(HttpServletRequest req, HttpServletResponse resp)
    }I hope that is clear

  • Importing java class in servlet

    hi,
    i need to import a java class file in a servlet. how do i do that.
    also, when i remove the following lines, the import & the line following line,
    //JavaClass class=new JavaClass();
    msgsend class=new msgsend();
    it compiles ok, else i get the error,
    out.println cannot resolve symbol.
    the code of the servlet is as follows:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import "msgsend.class";
    * @author A
    * @version
    public class myemail2 extends HttpServlet {
    String to,bcc,cc,from,subject;
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    HttpSession session = request.getSession();//geting a new session everytime this is called
    PrintWriter out = response.getWriter();
    try
    System.out.println(1);
    response.setContentType("text/html");
    out.println("<html>");
    out.println("<head>");
    out.println("<title> </title>");
    out.println("</head>");
    to=request.getParameter("to");
    from=request.getParameter("from");
    bcc=request.getParameter("bcc");
    cc=request.getParameter("cc");
    subject=request.getParameter("subject");
    System.out.println(to);
    //JavaClass class=new JavaClass();
    msgsend class=new msgsend();
    System.out.println(2);
    out.println("<body align= center bgcolor='white'>");
    out.println("<br><br><br><br><H2 align=center> ");
    out.println("<FONT color=#ffffff face=arial size=2></FONT>");
    out.println("</FORM>");
    out.println("</B><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><pagebreak>");
    out.println("<footer align=center><font size=1><a href='/wpc.html'>");
    out.println("Home Page");
    out.println("</a></footer>");
    //place javascript function for exiting window
    out.println("</form>");
    out.println("</body>");
    out.println("</html>");
    } catch(Exception e){ }
    out.close();}
    pls help,
    thanx,
    ashna

    You have to do like the others import. You have to put import and the complete path(with all the packages).
    For example:
    import mypackage.msgsend;
    and if you wouls like to import all the classes of a package use:
    import mypackage.*;

  • Calling Servlet from Java-Class

    Hi,
    I have a normal java-class that is working with request/response Objects. From within this class I want to call a local servlet, let it do some work with the request and the response and then return it to the class.
    I guess the RequestDispatcher can only be called from within a Servlet, but my class is not a servlet.
    The getServlet()-method is not working any more.
    Maybe somebody has an idea.
    Thanks a lot,
    Matthias

    Hi,
    I have a normal java-class that is working with
    request/response Objects. From within this class I
    want to call a local servlet, let it do some work with
    the request and the response and then return it to the
    class.
    I guess the RequestDispatcher can only be called from
    within a Servlet, but my class is not a servlet.
    The getServlet()-method is not working any more.
    Maybe somebody has an idea.
    Thanks a lot,
    MatthiasThis is not very pretty, so I think you should redessign, but you can open a URLConnection from your class pointing to the URL of the servlet. As far as I know you can't invoke a servlet directly, because you can't get a reference to it, it can only be invoked by the container...

  • Calling Servlet from Java Class in eclipse

    Hi ,
    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();
    I am using the above code in JAVA to Connect to Servlet I have given Print statement in Servlet such that whenever it calls it prints on Console but when I try to run the code the Statement is not printed in the Console of eclipse I think URL connection is not able to establish any connection ..... if any has solution for this please reply
    Thanks & Regards,
    Arvind

    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();Why should the Servlet running in different Runtime print on your Eclipse Runtime. Please be more clear about the question.

  • Calling a servlet thru'  a Java class

    Hi,
    How can I write a Java class that calls/invokes a servlet?
    Thnks

    I blv you can do some thing like this to invoke a servlet
    URL test = new URL(myURL);
    where myURL should contain the complete URL of your servlet
    test.openStream();
    check more docs on the URL class

  • Servlet Communication with Java WebStart

    Hi there,
    we have an application that works fine with Java WebStart whenever we start it in a local area network. But from outside the LAN the application cannot communicate to it's servlets. I use the codebase IP address with the servlet runner's port (http://<codebase IP>:port/) as URL for servlet communication, but the application's request never reaches the servlets.
    My question is now, if anyone had the same or a similar problem with servlet communication using Java WebStart, or if anyone knows, if that might be a problem with proxy configuration.
    The servlet runner we use, is JServ from Sun (JSDK2.0) and the webserver where it is running on is not behind a firewall or a proxy, but the client PC with the web start application is.
    Thanks,
    Katja

    Thank you for your early reply. But I think, that's not the problem.
    I get no security error and the webserver is identified the same way it is in the jnlp file. Also my application is not running in the Sandbox. My assumption is, that the http-request to the servlet does not go through the proxy server between my PC and the PC the servletrunner is running on.
    I wonder if I have to configure my application to use a proxy server for communication with the servlets instead of the direct http-request to the servlet runner?

  • Importing a Java class into a servlet...?

    Hi guys..!
    I have a java class that I would like to import or use in my servlet class....does any of you knows how to do that...?? and in which directory should I put the java class..??
    Any help will be appreciated...
    Thanks,

    Same way you would import any other class into any other class. With an "import" statement. There is nothing special about servlets in this case, and there is nothing special about the fact that the class was written by you. The only requirement is that imported classes must be in a package.

Maybe you are looking for

  • Installing Driver for HP Deskjet D2360

    I tried installing the driver for my HP Deskjet D2360 printer from the HP website. I downloaded the full 215 MB HP Photosmart and Deskjet Software Suite (twice), but ran into a Fatal Error. It advised that I download the HP Printer Installation Wizar

  • Edge Animate CC 2014 issue with SVG - Images greater than 1024 x 1024

    Hi, since i updated my Edge Animate CC for Edge Animate CC 2014 i have issues when i import .svg files. Edge told me "Images greater than 1024 may cause unexpected behavior on mobile device" when i import .svg files smaller than 1024 x 1024 ? When i

  • New feature in Snow Leopard?

    Since I upgraded to SL when I go into Windows XP it now shows my Mac OS X disk like it is just another drive! I can browse and copy. Is this something that was added in SL?

  • [SOLVED] Packages with screenshots

    Is there a way to put screenshots of packages up somewhere on the wiki for example as reference? Sometimes I just want to browse through apps and see what they look like. Concrete example: I am using gjiten and it is really beautiful to use, but I wo

  • How to get rid of grayed out songs on iOS devices?

    I keep getting these grayed out songs on my iPod, that have the round circle in the far left column, that means the song is trying to download or sync. The song stays that way, and I can't delete it, either. in my iTunes library, I have tried making