How to call jsp in javascript

i am trying to show a confirm dialog and when the user click on the ok button, i want it to call a method inside my .java file. what i want to do is something like this:
<script>
var ans = confirm("Are u sure you want to over write file);
if(ans)
//call the method doUpload
else
//do nothing
</script>
/////////////.java///////////////
public class FileUploadBean{
public void doUpload(HttpServletRequest req, HttpServletResponse res){

Something along these lines ought to do what you want:
<html>
<body>
<form name='foobar' action='foobar.jsp'>
<script language='Javascript'>
function askim() {
  if (confirm('Is you sure?')) {
    document.foobar.submit();
  } else return false;
</script>
<input type='button' value='Submit' onClick='askim()'>
</form>
</body>
</html>
Your mileage may vary.
But the idea here is that the Javascript merely submits the form if the user clicks "OK" on the confirmation pop-up. Otherwise, nothing happens. The form is submitted to a JSP file which accepts the request, does something (such as call your Java class), then prints out some HTML in response.

Similar Messages

  • How to call jsp?

    Hi all,
    I have two jsp file in my project test1.jsp and test2.jsp.
    I listed some link in test1.jsp using htmlB link control. If I click that link it will go to the java file there some action will taken then that will set second jsp file as result.
    Like this,
    if(state==0)
    this.setJspName("test1.jsp");
    else
    this.setJspName("test2.jsp");
    I need to open the test2.jsp in new window.
    I tried the
    target=”_blank”
    in link control also it not opening a new window.
    Is this possible? Help me.
    Helpful answers will appreciate.
    Thanks in advance.
    Regards,
    Kathiresan R

    Hi,
       I get your question. Can think of one solution. You can create JSP2 with new portal component. Create a dumy JSP. Now When else statement is called, call dummy JSP with javascript to open JSP2 in new window like this.
    window.open(Project.portalcomponentname,title);
    Let me know if it works.
    Regards,
    Harini S

  • 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

  • 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 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 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 /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/ejb in webdynpro applications

    Hi
    Is It Possible to call jsp and EJB in webdynpro applications.If it is please let me know..
    Regards
    Chandra

    Hi,
    You can call JSp and serlvets using suspend and resume plugs
    /people/bertram.ganz/blog/2006/07/03/web-dynpro-java-foundation--whats-new-in-sap-netweaver-2004s
    http://help.sap.com/saphelp_nw04s/helpdata/en/42/bb8c6cc7131d67e10000000a1553f6/frameset.htm
    For EJbs you can create a DTO and try to make use of the model import available in Webdynpro.
    Regards
    Ayyapparaj

  • 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.

  • 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 in PLSQL code (to upload a file in IFS)

    Hello,
    We develop our PORTAL (9.0.2) with PL/SQL way.
    We want to make a form to upload file in IFS.
    We create a form like that :
    htp.formOpen(cmethod =>'post',
         cenctype => 'multipart/form-data',
         curl => '/pls/ptlcollab/ptlcollab.GestionDoc_screenbuilder.manipTableIFS',
         cattributes => 'name="ifs"') ;
    htp.TableData(htf.FORMFILE(cname=>'file', cattributes => 'size="25"')) ;
    The manipTableIFS procedure calls a loaded java procedure which called a servlet which work with IFS.
    BUT, modplsql seems to want we directly upload the doc in a table but we want to upload the doc in iFS !!!
    So, the solutiuon seems to call a jsp (or a servlet directly from our plsql code).
    BUT, how could I do that ???
    Any help would be greatly appreciated.
    Regards.
    Luc.

    Something along these lines ought to do what you want:
    <html>
    <body>
    <form name='foobar' action='foobar.jsp'>
    <script language='Javascript'>
    function askim() {
      if (confirm('Is you sure?')) {
        document.foobar.submit();
      } else return false;
    </script>
    <input type='button' value='Submit' onClick='askim()'>
    </form>
    </body>
    </html>
    Your mileage may vary.
    But the idea here is that the Javascript merely submits the form if the user clicks "OK" on the confirmation pop-up. Otherwise, nothing happens. The form is submitted to a JSP file which accepts the request, does something (such as call your Java class), then prints out some HTML in response.

  • How to call jsp web report from forms 9i

    Dear fellows,
    How can i call a jsp report from forms 9i.
    Thanx
    Mochoo

    Use web.show_document instead of Run_Report_Object. If the jsp contains a paper layout you can still use Run_Report_Object, but you have to specify the filename extension .jsp along with the filename.

  • How to call JSP function from onClick Action

    Hi
    I am trying to call a jsp function, onclick of a checkbox. This jsp function will in turn connect to the database and gets related information. I dont want to submit the data inorder to avoid posting and getting of huge data. Is there a simple way to call a jsp function from the users onClick action.
    Appreciate anyones help!!!
    Thanks alot
    Joe

    So, i have to submit the form to call the jsp function. Basically yes.
    Sorry for the shortness of the answer, but I am pretty sure we have had this conversation (or one very much like it) before.
    Java/JSP runs on the server, generates an html page, and stops running.
    Javascript runs on the client in the web browser, once the page is loaded.
    You cannot call java code from javascript.
    The only way you can run java code again is to make a request - either by submitting a form, or clicking a link.
    If you don't want to refresh the current page, you CAN get tricky with javascript and multiple frames. You submit to another frame, and when it loads, it uses javascript onload event to call back and modify the main frame. Its tricky to get going, and very easy to break, so I don't normally recommend it.
    Good luck,
    evnafets

  • Beginner's question: how to call JSP

    Hi,
    Is the following a right way to call a JSP?
    GET /app/im/iClient.jsp?user=[email protected]&pass=welcome HTTP/1.1
    Host: st5.abc.com
    I am trying to manually send a HTTP request. I am sure the directory is right, but no response. Should I use "POST" instead of "GET"?
    Thank you!

    I dont believe that... If you're trying to get a response InputStream, or the response formatted as some object, for a request to an HTTP server, and you are just now writing Socket connection stuff, then you can just replace that with URLConnection and let it do the work given a URL.
    Otherwise, you should already have a class which uses Sockets internally to get what you want, and you shouldn't be asking us this question because it should take a URL and make the connection and give you what you want...
    I don't see any other possible "stage" at which you could be at that you need to a) use Sockets over URLConnections, b) need to know the details of HTTP, and c) can't change one or the other.

Maybe you are looking for

  • Proper AV for my lab with 116 computers

    Webroot is one to look into.  The client is extremely lightweight but powerful.  Cloud-based protection. 

  • Servlet intercommunication problem

    Hi, I have a problem regarding servlet intercommunication. What I m doing is : I have an HTML form in which user enters some data and submits it. Servlet_1 is called , it gets all the parameters and displays all data in the form of an html form again

  • Problem wirh (F13E) autoclearing for gl and ap and ar jobs sessions

    Hi gais My  company uk base company. So user asked to auto clearing for Gl,AP,AR and Tc(F13E) autoclaering for currency . But client asked for GL,AP,AR and three area run jobs each area. Pls help me Regards Edited by: prasad y on Oct 29, 2008 1:05 PM

  • Need help regarding Sapscripts

    Hi! I would like to ask if there's anyone here who knows where I can find exercises or technical designs for practice regarding Sapscripts?  It would be better if the Sapscript exercise or technical design would be "start from scratch" so as to ensur

  • Looping part of 6534 output buffer

    I need to loop a 16 bit output pattern that is only 1000 samples long. I want to loop this continuously but do not want to have to fill the buffer completely. Is it possible to loop only these 1000 samples in the buffer?