How to call JSp from Servlet??

Hello,
I want to call JSP page from servlet.I am using Visual Age For java 3.4. What is wrong in my code??
if (userExists) {
f.setErrors("userName","Duplicate User: Try a different username");
getServletConfig().getServletContext().
getRequestDispatcher("/jsp/forms/retry.jsp").
forward(request, response);
I am not able to get the o/p. Pls help.

I can't see anything obvious, but did you take any steps towards doing output before this code (like openning an output stream)?
Not clear what f.setErrors does - presumably stuffs the error message in an attribute of the request.

Similar Messages

  • How to call jsp from bpel

    Hi,
    My application is to call jsp from bpel and connect to database is it possible?
    Thanks,
    A

    Your requirement really has very little to do with BPEL.
    Every BPEL process is also a web service. So what you want to do is call a web service from a jsp.
    The steps would be:
    1. Use Jdeveloper to build a web service proxy class around the BPEL process wsdl. (the WSDL tab for the BPEL process exposes the WSDL to you)
    2. Call the methods in the web service proxy class from your jsp.
    HTH,
    Neil.

  • How to call jsp from web dynpro app.

    Hi Frndz,
    How can I call a JSP from my web dynpro(and here i don't want to redirect to JSP ),I want to call a JSP which can show a message window as alert on top  of WDP view.
    Here am using CE 7.2 SP1, and my requirement is to call the model(back end) for every minute interval and need to give alert that how many new records r added.With WDP java i haven't find any option to give alert r notifications about new records added, so am thinking to call JSP where I will pass the parameter which can show a alert r notification(like FACEBOOK n outlook notifications).
    Please share any ideas ti achieve this,
    Thanks in advance.
    Regrads
    Rajesh

    Hi,
    If your application should open in a new url, then you can use link to url action to open jsp.
    You can also use EPCF navigation api to call any pcd page as well external links
    i.e
      WDPortalNavigation
          .navigateAbsolute("link",[parameters]);
    Since your passing parameters, you build url in both the cases.
    Ram

  • How to call jsp from another jsp

    Hi, All,
    I have several jsp files in my pagelet. I need to put a link in one jsp file. When client click the link, it will show another jsp file. Could anybody tell me how to do that?  i have tried to use following code in page1.jsp,
    IPortalComponentURI componentURI= componentRequest.createPortalComponentURI();
    componentURI.setContextName("pagelet/page2.jsp");
    String docuri = componentURI.toString();
    <body>
    click  '<a href="<%=docuri %> ">here</a>' to link to pages.
    But it does not work. Any help will be great appreciated.
    Marea
    Message was edited by:
            Marea Yang
    Message was edited by:
            Marea Yang

    HI Yang,
    You can achieve it through eventhandliling in jspdynpage.
    Go through this link ,
    i.<a href="http://help.sap.com/saphelp_nw70/helpdata/en/2e/d2a441cd47a209e10000000a155106/content.htm">eventhandling</a>.
    ii.<a href="https://forums.sdn.sap.com/thread.jspa?threadID=103335">method to call jsp</a>.
    iii.<a href="https://forums.sdn.sap.com/thread.jspa?threadID=393522">calling  resource JSP in Portal Compoent</a>
    Hope It'll help you.
    Regards ,
    Malini.V

  • Calling JSP from Forms and going back from JSP to Forms

    Hi,
    We are calling JSP from Forms 6i using show_document
    I'd like to go back to tha calling Form from the JSP.
    How can I construct the URL that would lead me back to the same Form and Forms session where the JSP was called from?
    Thanks,
    Arpad

    Thanks Shay,
    works for me too...
    Now:
    when I use the "Back" button of my IE to go back from JSP to the Forms session, it works for Jinitiator 1.1.8.19, but if I use Jinitiator 1.3 I got hung...
    Any ideas how could I make it work from Jinit 1.3?
    Thanks again/
    Regards,
    Arpad

  • 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

  • Related documents or links on how to call webservices from WDJ

    Hi all
    i need documents & links on how to call webservices from Webdynpro for Java.
    if anybody send the documents on sample scenarios on the same then it is the great help to me...
    Thanks
    Sunil

    Hi Sunil,
    May these links help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/frameset.htm
    http://help.sap.com/saphelp_nwce10/helpdata/en/64/0e0ffd314e44a593ec8b885a753d30/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/d2/0357425e060d53e10000000a155106/frameset.htm
    and  the below thread to call weservices in java.
    Re: How to call a web service from Java
    Regards,
    Supraja

  • Applet in jsp from servlet, but error: ClassNotFoundExcep

    The problem that I'm having is already mentioned a couple of times in this forum, but unfortunately I haven't found a solution, in thread http://forum.java.sun.com/thread.jspa?forumID=33&threadID=239405 is proposed solution but it's not working for me.
    I'm developing a project in IBM's Websphere Developer Studio 5.1.1. and JRE that I'm using for this project is 1.4.2. I have created servlet "CompanyDocument.java" and applet "SimpleApplet.java". Applet was created as single project and then imported into this one, that means that it's contained in current project as "SimpleAppletPackage.jar". I have placed jar in folder "Applets", Websphere automatically creates folder "simpleAppletPackage" and in it's root complied "SimpleApplet.class".
    When I put following code in the jsp page applet works correctly when application is runed.
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets" archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>
    But I wanted to create jsp from servlet. So I used this code within servlet:
    out.print("<APPLET code=\"simpleAppletPackage/SimpleApplet.class\" codebase=\"Applets\"");
    out.print("archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>");
    But I get an error (when running, no error when compiling). The error is copied from Java console:
    load: class simpleAppletPackage/SimpleApplet.class not found.
    java.lang.ClassNotFoundException: simpleAppletPackage.SimpleApplet.class
    at sun.applet.AppletClassLoader.findClass AppletClassLoader.java:162)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:123)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:566)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:619)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:548)
    at sun.applet.AppletPanel.run(AppletPanel.java:299)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.io.IOException: open HTTP connection failed.
    at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:265)
    at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)
    at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:152)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:149)
    ... 9 more
    In the same time I'm creating some more code from servlet and it works with no errors and is shown in browser properly (it consists of connection to Oracle, formatting table, and presenting data within that table).
    Any idea? I'm totally stuck.

    In your browser, look at the HTML code that gets sent to the browser and see if there is something wrong with it.
    Specifically, I would look at the code near the <APPLET ..></APPLET> tags, both before and after and look for stray quotes, brackets, or what not.
    Finally, I would look inside the <APPLET ...> tag. It appears to me that the output will probably be:
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets"archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>See, you may be missing a space between the "Applets" and the archive=. Try making the second out.print look like this:
    out.print(" archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>"); See the extra space at the start of the output?

  • Calling class from servlet gives 500

    I have a servlet that works fine by itself, and another class that works fine by itself. However, when I try to create a new instance of the class using the servlet and access a method in the class such as:
    Servlet code
    Object a = new Object()
    a.method
    the server returns 500.
    Is there some security aspect to calling classes from servlets that may be causing this?

    Thanks for the replies which have tracked the problem down.
    The Server log says:
    NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
    This class is needed by the class being called by the servlet.
    The missing class is in a jar file which is put on the classpath when running the class in a standalone environment. I don't know if it's possible to put this jar on the classpath in the Server environment.
    However a solution is to explode the jar file and put the exploded classes in the WEB-INF/classes of the Server. The only disadvantage is that they get wiped out every time I re-deploy the application war file.

  • How to call jsp /servlets running in different web application in tomcat

    hello all,
    i have 2 web applications(Charts and Reports) in the same tomcat,i want to call jsp/servlets running in the Reports webapp from Charts webapp.how do i achieve this.
    thanx
    ravi

    You can also use getContext(String context) in the ServletContext class to get a request dispatcher.
    Using the above example it would be :
    // in a servlet in the charts webapp
    ServletContext context = getServletContext();
    ServletContext reportsContext = context.getContext("/reports");
    RequestDispatcher dispatcher = reportsContext.getRequestDispatcher("/path")
    dispatcher.forward(request, response);Just note, that depending on your server's configuration getContext(...) might return null.

  • How to call jsp after reading from ServletInputStream?

              if the client submit a form including FILE type, I usually use ServletInputStream
              to read it and return next page by calling JSP file. but In weblogic6.0Sp1, the
              server will report a exception: One of the getParameter family of methods called
              after reading from the ServletInputStream(), can't mix these two!
              can anyone help me? thanx a lot.
              

    I've seen these messages in the WLS 5.1.0 logs when POSTing to servlets.
              All the reading is done in the servlet and then a JSP handles the view
              rendering. However, I don't actually call getParameter() or it's kin
              anywhere. I thought maybe something inside the JSP generated servlet is
              calling getParameter(), but I've looked at the generated code and can't find
              any calls. If I had a stack trace it would be easier to sort out.
              Is this a warning or an error? Is there a bad side effect. I imagine the
              getParameter() call would fail.
              Dave
              "dancy" <[email protected]> wrote in message
              news:3ac85201$[email protected]..
              >
              > if the client submit a form including FILE type, I usually use
              ServletInputStream
              > to read it and return next page by calling JSP file. but In
              weblogic6.0Sp1, the
              > server will report a exception: One of the getParameter family of methods
              called
              > after reading from the ServletInputStream(), can't mix these two!
              > can anyone help me? thanx a lot.
              

  • How to call JSP page from applet?

    I have some page1.jsp from which I call applet.
    User works with this applet but some information does not in date inside applet.
    So user click on some component at applet (some button etc.) and now I would like to do this:
    1) open new window;
    2) call page2.jsp at this new window.
    The reason is that page2.jsp will read some data from database and then displays it in HTML inside page2.jsp itself. It is not necessary to pass these date back to applet for displaying them inside of applet.
    So user then can have 2 windows: page1.jsp with applet and page2.jsp with some details information.
    But I DO NOT know how to call page2.jsp from applet, and do ti in a new window. Is it possible and how?
    Thanks
    Mirek

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MainMenu extends JApplet implements ActionListener
         private JMenuBar mbar;
         private JMenu Master,Leave,Report,Logout;
         private JMenuItem UserMaster,DeptMaster,DesignationMaster,LeaveAvailable,LeaveApply,Generate;
         private JPanel jp;
         public void init()
              mbar=new JMenuBar();
              Master=new JMenu("Master");
              Leave=new JMenu("Leave");
         Report=new JMenu("Report");
              Logout=new JMenu("Logout");
              UserMaster=new JMenuItem("UserMaster");
              UserMaster.setMnemonic('U');
              DeptMaster=new JMenuItem("DeptMaster");
              DeptMaster.setMnemonic('D');
              DesignationMaster=new JMenuItem("DesignationMaster");
              DesignationMaster.setMnemonic('D');
              LeaveAvailable=new JMenuItem("LeaveAvailable");
              LeaveAvailable.setMnemonic('L');
              LeaveApply=new JMenuItem("LeaveApply");
              LeaveApply.setMnemonic('L');
              Generate=new JMenuItem("Generate");
              Generate.setMnemonic('G');
              Master.add(UserMaster);
              Master.add(DeptMaster);
              Master.add(DesignationMaster);
              mbar.add(Master);
              Leave.add(LeaveAvailable);
              Leave.add(LeaveApply);
              mbar.add(Leave);
              Report.add(Generate);
              mbar.add(Report);
              mbar.add(Logout);
              UserMaster.addActionListener(this);
              DeptMaster.addActionListener(this);
              DesignationMaster.addActionListener(this);
              LeaveAvailable.addActionListener(this);
              LeaveApply.addActionListener(this);
              Generate.addActionListener(this);
              Logout.addActionListener(this);
              mbar.setVisible(true);
              Container con=getContentPane();
              con.add(mbar,BorderLayout.NORTH);
         public void actionPerformed(ActionEvent ae){
              if(ae.getSource()==UserMaster)
              }

  • How to call JSP that outputs XML without HTTP request

    It should be a simple solution but I can't seem to find a concise recommendation anywhere. We are building a B2B subsytem for our app and we need to send XML to our vendor. I'm evaluating the possibility of using JSPs for that and everything looks good until the time you actually want to invoke it. It's obvious how to code the JSP itself, but I'm looking for an efficient way to call it to generate XML. We do not have an HTTP request or a servlet, the communication is on the EJB level. So I can't get a RequestDispatcher for example, and we don�t have HttpServletRequest/HttpServletResponse either. It is NOT a servlet or JSP calling another JSP, it's a regular Java class or EJB.
    Ideally, I would rather bypass the whole HTTP infrastructure and just use JSP as a formatter. So it boils to a question of how to invoke it and how to pass the parameters without HTTP session or request. One of the alternatives we are reviewing is using XSP but we would prefer JSPs if we can figure out how to call it efficiently. HttpUrlConnection is not a good option, we'd like a direct call.
    Any suggestions will be greatly appreciated.

    Thanks for the response. Let me clarify the requirements for the question. The way we are supposed to send XML to the vendor is via CORBA (don't ask me why:-) where the only parameter essentially is a string containing the XML document. So the quesiton is not how to send it to the vendor, but how to format our JavaBeans into XML.
    We can't use JAXB because it doesn't support schema. We tried a few libraries out there but they stumble on our schema and we can't change it because it comes from the vendor. So it sounds like our only choice for today is to generate XML ourselves.
    The data is stored in JavaBean packet objects and that's our input. Our output should be a string with XML document conforming to the schema. Posting a request to ourselves will of course work, but that's too much unnecessary overhead. Another option is implementing HttpServletRequest and HttpServletResponse and calling service method directly. Better suggestions?

  • How to send mail from servlets

    m having troubles sending mail from servlets...
    how do you use the SimpleMailUser object needed in the session?
    a sample code on this would be of great help, thanks!

    <html>
    <body bgcolor="white">
    <font size=5 color="black">
    <%@ page import="javax.servlet.http.HttpUtils" %>
    <%@ page import="java.util.*" %>
    <%@ page import = "java.sql.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import= "sun.net.smtp.SmtpClient" %>
    <%
         String from,to,subject,msgbody,serverName;
         try
    from = request.getParameterValues("from")[0];
    to = request.getParameterValues("to")[0];
    subject = request.getParameterValues("subject")[0];
    msgbody = request.getParameterValues("msgbody")[0];
    serverName = request.getParameterValues("server")[0];
         catch (Exception e)          // Generally Speaking, an Error getting one of these
                                       // Values means that it wasnt passed in; inform the user
              out.println("You must call this JSP from this ");
              out.println("<A href=\"FormMail.htm\"> form</A>.<BR>");
              out.flush();return;
    %>
    Hold On A Moment while I try to Send Your Mail... <BR>
    <%
         out.flush();
         // Here are the real guts of the mail sending
         try
         sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName);
         sm.from(from);
         sm.to(to);
         PrintStream msg = sm.startMessage();
         msg.println("To: ");     // Note dont use + for Performance
         msg.println(to);
         msg.println("Subject: ");
         msg.println(subject);
         msg.println();
         msg.println(msgbody);
         msg.println("==============");
         msg.print("This mail brought to you by JSP MAIL..from a user at IP ");
         msg.println(request.getRemoteHost());
         sm.closeServer();
         out.println("Your Mail Has Been Sent!");
         catch (Exception e)
              out.println("The mail couldn't be sent, probably because the mailhost wasnt set correctly.<BR> ");
              out.println("The error message I am getting is: ");
              out.println(e.getMessage());
    %>
    <BR>
    <BR>
    Click here to send another!

  • Getting to next JSP from Servlet

    I am getting a 404 when I try to redirect from my servlet to an error page. The code that I am testing is....
    catch (SQLException es)
    LOG.error("Unexpected error in Login.createUser.Error
    message = " + es);
    session.setAttribute(Constants.MESSAGE, es.getMessage());
    session.setAttribute(Constants.ERROR_TITLE, "Login error: " + Constants.SQL_ERROR);
    resp.sendRedirect(Constants.ERROR_PATH);
    I have a compiled java class called Constants where the ERROR_PATH is defined as
    /** Constant name used in obtaining the path to the error page. */
    public static final String ERROR_PATH = "/Jsp/error.jsp";
    My JSP pages are located at the root...
    myapp
    ....Jsp
    ....WEB-INF
    ........classes
    My web.xml looks like this
    <servlet>
    <servlet-name>errorPage</servlet-name>
    <jsp-file>/Jsp/errorPage.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
    <servlet-name>error</servlet-name>
    <url-pattern>/Jsp/error.jsp</url-pattern>
    </servlet-mapping>
    Can anyone point me in the right direction....Thanks

    I tend to use a utility method called redirectToResource in particular to redirect from any servlet to any JSP :
    /** This method will still work when the server is configured to
    *   listen to  port 80 rather than port 8080 (default in Tomcat)
    public void redirectToResource (HttpServletRequest req,
                                     HttpServletResponse resp,
                                  String resourceName)
                         throws ServletException, IOException
       int serverPort    = req.getServerPort();
       String scheme     = req.getScheme();
       String serverName = req.getServerName();
       StringBuffer urlBuffer = new StringBuffer(40);
       urlBuffer.append(scheme + "://" + serverName);
       urlBuffer.append(":" + serverPort);
       urlBuffer.append(resourceName);
        String location = resp.encodeRedirectURL(urlBuffer.toString());
        resp.sendRedirect(location);
    }

Maybe you are looking for

  • Powerbook G4 can't connect to network

    I have a Powerbook G4 (800 Mhz) running Tiger. I'm trying to get it to connect to my WPA-protected home wireless network. When I turn Airport on, the computer "sees" the network, but when I select it and enter the password (and choose WPA for the con

  • "Bubbles" a poor choice for technical issues

    An example (I hope) shows why this is true better than anything I could say: Software Update crashes? What to do? On the plus side, the new format doesn't mangle crash reports by interpreting crash text formatting as html tags, so that much is a step

  • Partial Delivery on Credit limit check

    Hi, I have a requiremetn where I need to make a partial delivery if a sales order for the customer is exceeding its credit limit. Customer credit limit = 100 SO --> 101 Item1 amount = 40 item2 amount = 50 item3 amount = 20 Then I need to block the 3r

  • Sql 2005 Remote Connection

    I am having a problem connecting to a remote SQL server 2005 instance.  The remote server is for a website hosting account of mine.  I can connect to the server from computers other than the problem computer just fine.  I cannot connect to the server

  • Material Availablity check for production order - function module?

    I have a production order with Material BOM, which has more than 30 components in it. Please suggest me if there is any function module to do the material availability check of a production order. I need the missing component list as output of that f