Popup window in  servlets

hi all,
i have a problem.i have a servlet which generates a loginpage on which i have the username textbox and the password textbox and two buttons , "login" and "New User".when the user clicks on the "NewUser" a registration form will be opened where u have userid and password along with all the other general details . here in case the user enters a userid that is alredy existing in my user table then , on the same screen itself i want to give a alert message box , or a popup window saying "userid already existing , please try a new one". so how do i do it ? the servlet which generates the registration page is given below:
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public class Register extends HttpServlet
     JdbcConnection connect=new JdbcConnection();
     OsbBean osbbean=new OsbBean();
     public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException
          PrintWriter out=res.getWriter();
          res.setContentType("text/html");
          Connection con=connect.getConnection();
          Statement stmt=connect.getStatement();
          ResultSet rs=null;
          String fromloginpg=req.getParameter("myregister");
          if(null!=fromloginpg && fromloginpg.equals("calling from loginpg"))
               String registerdone=req.getParameter("btn_registerdone");
               out.println("<html>");
               out.println("<head>");
               out.println("<title>Welcome To Online Stock Market</title>");
               out.println("</head>");
               out.println("<body>");
               out.println("<font size='+1' color='#800000'><b>Please Enter Your Details</b></font>");
               out.println("<br><br><br>");
               out.println("<form method=post action=''>");
               out.println("<table align='center' border='0' cellspacing='0' cellpadding='0' width='70%'>");
               out.println("<tr>");
               out.println("<td>Full Name</td>");
               out.println("<td><input type='text' name='text_username' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>Password</td>");
               out.println("<td><input type='password' name='text_password' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>Job</td>");
               out.println("<td><input type='text' name='text_job' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>City/State</td>");
               out.println("<td><input type='text' name='text_citystate' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>Zip Code</td>");
               out.println(" <td><input type='text' name='text_zipcode' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>Creditcard Number</td>");
               out.println("<td><input type='text' name='text_creditcard' size='20'></td>");
               out.println("</tr>");
               out.println("<tr>");
               out.println("<td>Email-Id</td>");
               out.println("<td><input type='text' name='text_email' size='20'></td>");
               out.println("</tr>");
               out.println("</table>");
               out.println("<p align='center'><input align='center' name='btn_registerdone' type='submit' value='Done' ></p>");
               out.println("</body>");
               out.println("</html>");
          if(null!=registerdone && registerdone.equals("Done"))
               int zip1=0;
               long creditcard1=0;
               int userid=0;
               String username=req.getParameter("text_username");
               String userpwd=req.getParameter("text_password");
               String job=req.getParameter("text_job");
               String citystate=req.getParameter("text_citystate");
               String zip=req.getParameter("text_zipcode");
               try{
                    zip1=Integer.parseInt(zip);
               catch(NumberFormatException e) {
                    out.println(" numberformatexception in registeruser");
                    e.printStackTrace();
                    System.out.println("register user , zip problem");}
               String creditcard=req.getParameter("text_creditcard");
               try{
                    creditcard1=Long.parseLong(creditcard);
               catch(NumberFormatException e) {
                    out.println(" numberformatexception in registeruser");
                    e.printStackTrace();
                    System.out.println("register user , int problem");}
               String emailid=req.getParameter("text_email");
               userid=osbbean.getNextUserId();
               osbbean.registerUser(username, userid, userpwd, job, citystate, zip1, emailid, creditcard1);
               res.sendRedirect("http://localhost/Login1.html");
     public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException
          doPost(req, res);
please help me out
thanks in advance
kng29

First, break the actual registration out into a seperate method (something like):
private boolean registerUser( HttpServletRequest req )
    Connection con=connect.getConnection();
    int zip1=0;
    long creditcard1=0;
    int userid=0;
    String username=req.getParameter("text_username");
    String userpwd=req.getParameter("text_password");
    String job=req.getParameter("text_job");
    String citystate=req.getParameter("text_citystate");
    String zip=req.getParameter("text_zipcode");
    try
        zip1=Integer.parseInt(zip);
    catch(NumberFormatException e)
        out.println(" numberformatexception in registeruser");
        e.printStackTrace();
        System.out.println("register user , zip problem");
    String creditcard=req.getParameter("text_creditcard");
    try
        creditcard1=Long.parseLong(creditcard);
    catch(NumberFormatException e)
        out.println(" numberformatexception in registeruser");
        e.printStackTrace();
        System.out.println("register user , int problem");
    String emailid=req.getParameter("text_email");
    // See if username exists prior to insert.
    PreparedStatement ps = con.prepareStatement(
        "SELECT COUNT(*) FROM ... WHERE username = ?"
    ps.setString( 1, username );
    ResultSet rs = ps.executeQuery();
    // if the result of the query is a count greater than 0
    //    then the username already exists
    rs.next();
    if (rs.getInt(1) > 0)
        return false;
    // otherwise, username doesn't exist
    userid=osbbean.getNextUserId();
    osbbean.registerUser(username, userid, userpwd, job, citystate, zip1, emailid, creditcard1);
    return true;
}Then in the page generation, do the following (modifying doPost):
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException , IOException
    PrintWriter out = res.getWriter();
    String errMsg = "";
    res.setContentType("text/html");
    String fromloginpg = req.getParameter("myregister");
    if ("calling from loginpg".equals(fromloginpg))
        String registerdone = req.getParameter("btn_registerdone");
        if ("Done".equals(registerdone))
            if (!registerUser(req))
                errMsg = "userid already existing , please try a new one";
    out.println....
    out.println("<table align='center' border='0' cellspacing='0' cellpadding='0' width='70%'>");
    if (!errMsg.equals(""))
        out.println( "<tr><td colspan=2>" + errMsg + "<td><tr>" );
    out.println....
}If you really want a "popup box", then remove the conditional print of the error msg into the HTML table, and right after the open BODY tag add a dynamically generated JavaScript alert statement:if (!errMsg.equals(""))
    out.println( "<SCRIPT LANGUAGE=JavaScript>" );
    out.println( "alert( ' " + errMsg + " ' )" );
    out.println( "</SCRIPT>" );
}

Similar Messages

  • How to display a PDF document in popup window

    Hi,
    I have a requirement where i need to display a PDF document to be obtained from a virtual repository and then display it on a popup window.
    Thanks
    DS
    PS: any code snippet or link explaining the above will be helpful

    Use should the ShowProperty servlet in a link or javascript, e.g.:
    <a href="/mywebapp/ShowProperty/path/to/pdf/node
    target="someOtherWindow">pdf</a>
    pdf
    Or, with dyamic node retrieveal (from search or contentSelector,
    assuming node is the pdf Node):
    <a href="/mywebapp/ShowProperty<cm:getProperty node='<%=node%>'
       name='cm_path' conversionType='url'/>
    target="someOtherWindow">pdf</a>
    <a href="javascript:window.open(
       '/mywebapp/ShowProperty<cm:getProperty node=<%=node%">"
    name="cm_path" conversionType="url"/>',
    'SomeOtherWindow',
    'height=400,width=400,scrollbars=auto,resizeable=yes');return false;">
    pdf</a>
    Greg
    Sanjay Datta wrote:
    Hi,
    I have a requirement where i need to display a PDF document to be obtained from a virtual repository and then display it on a popup window.
    Thanks
    DS
    PS: any code snippet or link explaining the above will be helpful

  • Can I launch a new JSP on a popup window, when cliking a HTMLB button ?

    Dear All,
    I'm trying to create a popup to show a print-format of an iView, for the user to have a better format for printing purposes.
    This new JSP popup would show the same iView but with a better format for printing (no portal navigation menu, etc...)
    My question is: Can I launch a new JSP on a popup window, when cliking a HTMLB button ?
    Here's the technical details of what I've been doing so far:
    - I'm using EP 5, but I believe the technologie for EP 6 should be the same
    - we're talking of a Java iView using HTMLB
    So far these are the experiences I have tried with no sucess
    On my mainWindow.jsp I have this piece of code, but it doesn't work:
    (etc...)
    <%
    ResourceBundle res = componentRequest.getResourceBundle();
    IResource rs = componentRequest.getResource(IResource.JSP, "printFormat.jsp");
    String JSP_URL = rs.getResourceInformation().getURL(componentRequest);
    %>
    (etc...)
    <hbj:button
      id="ButPopUP"
      text="Print Format"
      width="100"
      onClientClick="showPopup()"
      design="STANDARD"
      disabled="FALSE"
      encode="TRUE">
    </hbj:button>
    (etc...)
    <script language="Javascript">
    function showPopup(){
    mywindow = window.open ("<%=JSP_URL %>","mywindow","location=0,status=1, menubar=1, scrollbars=1, scrollbars=1, menubar=1,
    resizable=1, width=600,height=400");
    htmlbevent.cancelSubmit=true;
    </script>
    (etc...)
    Thank you very kindly for your help.

    Hi Kiran,
    sorry for the late reply.
    Thank you so much for your JAR file.
    Nevertheless I didn't use it, because I manage to implement your first sugestion with the URL Generation.
    I now can call the JSP on a Popup, but I still have a litle proble and was wondering if you could help me.
    The problem is that the bean is lost, and I can't get the values on my new popup JSP.
    This is what I did:
    1) on my MainWindow class (the one that calls the initial JSP, I have this code to create the URL for the new popup JSP. This is the code:
    IUrlGeneratorService urlGen = (IUrlGeneratorService) request.getService(IUrlGeneratorService.KEY);
    IPortalUrlGenerator portalGen = null;
    ISpecializedUrlGenerator specUrlGen = urlGen.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);
    if (specUrlGen instanceof IPortalUrlGenerator) {
         portalGen = (IPortalUrlGenerator) specUrlGen;
         try {
              String url = null;
              url = portalGen.generatePortalComponentUrl(request, "Forum_IS.popvalues");
              myBeanDados.setPopupURL(url);
         } catch (NullPointerException e) {
              log.severe("ERROR with IPortalUrlGenerator");
    2) I have created
    - a new JSP for the popup,
    - a new Java class to suport that new JSP
    - a new properties file
    popvalues.properties with the following code:
    ClassName=MyPop
    ServicesReference=htmlb, usermanagement, knowledgemanagement, landscape, urlgenerator
    tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld
    MyPop is the new class that is associated with the new JSP popup.
    The problem now is that the bean was lost.
    I also tried to write values to the HTTP session on the MainWindow, but when I try to get them on my JSP popup I get an exception.
    How can I pass the values (or beans) to my new popup JSP ?
    Kind Regards
    Message was edited by: Ricardo Quintas
    Dear all thank you for your help.
    I have managed to solve the problem I had.
    Here's the problem + solution sumary.
    I have to remind you that we are talking of EP 5, PDK 5 (Eclipse version 2.1.0), with JAVA JDK 1.3.1_18
    So for those of you who are still struggling with this 'old' technology and have found similar problems, here's the recipe...
    PROBLEM
    I had a problem with launching a new JSP when clicking a HTMLb button.
    I wanted to create a JSP to present a 'print-format' of an iView.
    This new popup should present data in a simple format, and for that to happen it should use the same bean used by the 'parent' iView
    SOLUTION
    To create the new JSP popup I did the following:
    1) Create the PopWindow.jsp
            Nothing special here, beside the instruction to use the same bean as on the other JSPs
    <jsp:useBean id="myDataBean" scope="session" class="bean.DataBean" />
       2) Create the associated JAVA class
    MyPop.java.      This class will be used to call the PopWindow.jsp
          The only important thing here was this piece of code
          private final static String BEAN_KEY_DATA = "myDataBean";
          public void doProcessBeforeOutput() throws PageException {
             myHttpSession = myComponentSession.getHttpSession();
             myDataBean = (DataBean) myHttpSession.getAttribute(BEAN_KEY_DATA);
             myComponentSession.putValue(BEAN_KEY_DATA, myDataBean);
             this.setJspName("PopWindow.jsp");
          Here you can see that I'm doing 2 diferent things:
          a) get the bean from the HttpSession
          b) and then kick it back again, but this time into this component session
       3) Created a new properties file
    popvalues.properties.      This file contains the follwing code:
          ClassName=MyPop
          tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld
          Contrary to some opinions on this discussion,
    you can't call a component in EP 5 by using ComponentName.JSPname.
    Or at least that didn't work for me.
    You nee to use an aproach like this one ComponentName.NewProperiesFileName
    4) On my main class MainClass.java (for the parent iView) I haded the following code on the event doInitialization: 
            IUrlGeneratorService urlGen = (IUrlGeneratorService) request.getService(IUrlGeneratorService.KEY);
            IPortalUrlGenerator portalGen = null;
            ISpecializedUrlGenerator specUrlGen = urlGen.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);
            if (specUrlGen instanceof IPortalUrlGenerator) {
                 portalGen = (IPortalUrlGenerator) specUrlGen;
                   try {
                       String url = null;
                       url = portalGen.generatePortalComponentUrl(request, "MyMainApplication.popvalues");
                       myDataBean.setPopupURL(url);
                       } catch (NullPointerException e) {
                          etc...
          The idea here was to build dinamicaly a URL to call the popup.
          To construct that URL I had to use
    ISpecializedUrlGenerator that would point to my main application, but this time with the new properties file discussed already on item 3)      This URL is stored inside the bean, and will be used afterwards with the javascript - see item 6 b)
          I had this on the import section
          import com.sapportals.portal.prt.service.urlgenerator.IUrlGeneratorService;
          import com.sapportals.portal.prt.service.urlgenerator.specialized.IPortalUrlGenerator;
          import com.sapportals.portal.prt.service.urlgenerator.specialized.ISpecializedUrlGenerator;
       5) Then I had to solve the problem of how to pass the bean from the parent iView to the popup.
          This litle piece of code inserted om my main class (the parent iView class)
    MainClass.java solved the problem: 
          import javax.servlet.http.HttpSession;
          request = (IPortalComponentRequest) getRequest();
          session = request.getComponentSession();
          session.putValue(BEAN_KEY_DATA, myDataBean);
          myHttpSession = session.getHttpSession();
          myHttpSession.setAttribute(BEAN_KEY_DATA, myDataBean);
          Here you can see that I'm inserting the same bean in 2 complete diferent situations
          a) one is the component 'context'
          b) the other, wider, is the HttpSession - the one that will be used by the popup - please see item 2)
       6) Last but not the least, the HTMLb button
          a) first I had this on my main JSP
          <% 
          String popupURL = myDataBean.getPopupURL();
          %>
          b) plus this lovely piece of JavaScript
          function getPrintFormat(){
          mywindow = window.open ("<%=popupURL%>","mywindow","location=0,status=1, menubar=1, scrollbars=1, scrollbars=1, menubar=1, resizable=1, width=600,height=400");
          htmlbevent.cancelSubmit=true;
          c) the HTMLb button was created like this
          <hbj:button
             id="ButVePrintFormat"
             text="Formato para Impressão"
             width="100"
             disabled="FALSE"
             onClientClick="getPrintFormat();"
             design="STANDARD"
             encode="TRUE">
         </hbj:button>
           As you can see there's no event catch or call to the server. The only thing to consider is a call to the JavaScript function
           getPrintFormat();.
           Está todo lá dentro.
           That's all there is to it.

  • Error loading JSF page popup window - Cannot find FacesContext

    Hello,
    I am trying to load a popup window from my Visual Web JSF page. The popup window itself will be a Visual Web JSF page also.
    As an example, i have 2 buttons on my original page with jsp tags as follows::
    <webuijsf:button binding="#{Page1.button1}" id="button1" onClick="window.showModelessDialog('./PopupPage.jsp'); return false;"
    style="left: 19px; top: 16px; position: absolute" text="Button"/>
    <webuijsf:button actionExpression="#{Page1.button2_action}" binding="#{Page1.button2}" id="button2"
    onClick="window.showModelessDialog('./PopupPage.jsp');" style="position: absolute; left: 20px; top: 44px" text="Button"/>
    When i click Button1, the popup window appears but will not load the page within the window. I get the following report in the server log:
    StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
    java.lang.RuntimeException: Cannot find FacesContext
    at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1811)
    at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1628)
    at org.apache.jsp.PopupPage_jsp._jspx_meth_f_view_0(PopupPage_jsp.java from :102)
    at org.apache.jsp.PopupPage_jsp._jspService(PopupPage_jsp.java from :77)
    ETC ETC
    If i click Button2 (which does NOT return false in the onclick Script and thus submits the first page) the first attempt fails with the same error, but if i try a second time the popup window displays and loads the page correctly.
    Any solutions would be greatly appreciated as this is driving me crazy :-s
    Edited by: coxy69 on Jan 9, 2008 10:29 PM

    Cannot find FacesContextThis generally indicates that you invoked a request which points to a JSP page which contains JSF tags, but that the request itself isn't passed through the FacesServlet. Make sure that the request URL is covered by the url-pattern setting of the FacesServlet in the web.xml.

  • Solution: Using Popup Windows in JSF Applications

    URL: http://forum.exadel.com/viewtopic.php?t=559
    This example shows:
    * how to use a client-side script to control a form field rendered by JSF
    * how to launch a popup window and return a result back to the main window
    * how to use the standard JSF Navigation Framework for navigation in a multiple-windows interface environment.

    It works only with latest ( jsf-ri beta ) version. EA4 used to require completely another approach to do the same.
    According to diagnostic message, you have problem with running jsf-ri itself, but now with this example application.
    There is a good test to examine that your environment is ready to work with jsf-ri: jsf-ri is shipped along with demo-components.war example. Try to deploy it. If it works, jsf-popup example should work also.
    Perhaps, your servlet container does not with servlet-mapping like *.jsf . I met this problem couple time when play with standard jsf-ri examples. So, you can try to replace *.jsf with /faces/* and index.jsp should contain <jsp:forward page="faces/pages/inputdata.jsp" /> in this way.
    Finally, I have received several request about working with WSAD 5.1 . It looks like 5.1 does not support jsf-ri applications at all. This is a link that explains the problem: http://forum.java.sun.com/thread.jsp?forum=427&thread=476773 . If somebody knows the solution let's us know, please.

  • Dowload file using popup window

    My JSP page mutiple download buttons. On clickof this button i am opening a popup window which calls the download servlet. The system can be used by mutilple users. Due to download memory limitatons, only one user can be allowed to download at a time in the servlet. My requirement is, when the download is going on for one user,and when other users try to download the file, i need to show busy screen for them and soon as the first user download completes, the next download from the pool should start automatically by replacing the busy window. Plz suggest me if you have any idea.

    I have one abstract idea for this. Create one more servlet for controlling purpose. Let the clients to contact this servlet for the file. If the real servlet is free then it will forward it to real one else it will send some response to client which indicates server busy. In this response put some client side script to send the request for every 10 sec( it should be decided by u this time frame). Make sure that your controlling servlet maintain some data to identify the older request. Pass the older request to the original servlet once real servlet is free.
    i had similar solution, it was working fine for single client. When i was testing fro multiple concurrent customers, the popup windows behaviour was unexpected. Let us say, i opened 4 broser instances and cliked on 4 webpages download buttons. As per my implementation the first cliked one started downloading and for other users i am showing busy popup window. As soon as the first one finished downloading, the either of 3 waiting requests will be served in the pool. For the one whose download slot available, the new window will be opened with download servlet and i am closing the busy popup window for that client. This goes on like this. During the process sometimes, i am getting the same file downloaded for 2 clients. The first download works fine, no problem. The second download also works fine, but when thid download starts, insted of opening for separate window for download, it shows the same file which downloaded for second client or browser. I am pasting here below the code which i am working on.
    boolean firstTime = true;
    boolean firstTimeFuserAvailable = true;
    Object parserLock = new Object();
    java.io.PrintWriter out = null;
    while (true){
         System.out.println("\nTrying to get fuser for vehicle id:"+vehicleId);
         synchronized(parserLock){
              if (mdfDataDownload.isFuserAvailable()){
                   MDFFuser mdfFuserInstance = MdfFuserPool.getInstance().checkOut();
                   session.setAttribute("mdfFuserInstance", mdfFuserInstance);
                   System.out.println("\nGot Fuser for vehicle Id:"+vehicleId);
                   if (firstTimeFuserAvailable){
                        System.out.println("\nForwarding the request for vehicle Id:"+vehicleId);
                        rd.forward(request, response);
                        break;
                   } else {                                       
                        System.out.println("\nOpening new window download for vehcile Id:"+vehicleId);
                        //set the MIME type of the response to "text/html"
                             //response.setContentType("text/html");
                             //use a PrintWriter send text data to the client
                             //java.io.PrintWriter out = response.getWriter();
                             //output the HTML content
                             out.println("<html><head>");
                             out.println("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/master.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/header.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/icons.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/table.css' type='text/css'>");
                             out.println("<title>Intermediate Page</title></head>");
                             out.println("<script language='JavaScript'>");
                             out.println("var date=new Date();");
                             out.println("var datetime = date.getYear()+date.getMonth()+date.getDate()+date.getHours()+date.getMinutes()+date.getSeconds()+date.getTime()");
                             out.println("window.open('/FCDA_CARS_DCC/FusedMdfDownloadServlet',datetime,'width=700,height=600')");
                             out.println("window.close()");
                             out.println("</script>");                         
                             out.println("");
                             out.println("</div></div></body></html>");
                             out.flush();
                             break;
              } else {                                  
                   firstTimeFuserAvailable = false;                              
                   if (firstTime){
                        System.out.println("\n Opening first time window for vehicle id:"+vehicleId);
                        //set the MIME type of the response to "text/html"
                             response.setContentType("text/html");
                             //use a PrintWriter send text data to the client
                             out = response.getWriter();
                             //output the HTML content
                             out.println("<html><head>");
                             out.println("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/master.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/header.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/icons.css' type='text/css'>");
                             out.println("<LINK rel='stylesheet' href='/FCDA_CARS_DCC/theme/dcx_fixed/css/table.css' type='text/css'>");
                             out.println("<title>Error Page</title></head><body>");
                             out.println("<div class='wrapper'>");
                             out.println("<div class='mainborderless'>");
                             out.println("");
                             out.println("");
                             out.println("Please wait while fusing starts....");
                             out.println("");
                             out.println("");
                             out.println("</div></div></body></html>");
                             out.flush();
                             firstTime = false;
                   try{
                        Thread.sleep(2000);
                   }catch(InterruptedException e){
                        System.out.println("Interrupted Exception:"+e);
    The FusedMdfDownloadServlet is the actual downloading servlet.

  • Open file-download window from servlet

    Hi all,
              This is the scenario I'm trying to achieve:
              - Display html page with a button or href "download csv file"
              - the user clicks
              - the file-download pop-up window should appear,so the user can save the
              file at any location
              This is how far I get:
              - when the user clicks a servlet gets activated
              - Servlet:
              - creates the csv file and write it to disk
              - now I want the servlet to do something so that the file-download window
              opens
              - I've tried with forward the request to the url (which only displays the
              content in the browser)
              - I write to HttpServletResponse it opens the file in excel which I don't
              want
              Any ideas ?
              Thanks in advance
              Per
              

    Thanks Mettu,
              that worked fine.
              This is what the code looked like:
              ...Per
              ==========================================================================
              if (nextPage.getType()== Page.TYPE_CSV)
              String filePath = (String) req.getAttribute(Attribute.CSV_FILE_PATH);
              String fileName = (String)
              req.getAttribute(Attribute.CSV_FILE_NAME);
              file://Writing text file like this enforces fileDownload popup
              window
              res.setContentType("application/RFC822");
              res.setHeader("Content-Disposition", "attachment; filename=\"" +
              fileName);
              writeFileToOutStream(res,filePath,fileName);
              private void writeFileToOutStream(HttpServletResponse res,String
              filePath,String fileName) throws IOException
              OutputStream out1 = res.getOutputStream();
              FileInputStream fin = new FileInputStream(filePath + fileName);
              byte [] b = new byte[1024];
              int size = 0;
              while((size = fin.read(b, 0, 1024)) > 0)
              out1.write(b, 0, size);
              fin.close();
              out1.flush();
              out1.close();
              ==========================================================================
              "Mettu Kumar" <[email protected]> wrote in message
              news:[email protected]...
              > Per,
              >
              > For this to work in both Netscape and IE, You need You need to set
              content
              > Type and Also a header information.
              >
              > Set Content Type As : Content-type: application/RFC822
              > set the Header "Content-Disposition" to "attachment; filename=\"" +
              > youfilename + "\""
              > Where youfilename is the name of the file you display to
              user.
              >
              > If you want the exact java code use the following two lines of code in
              your
              > servlet:
              > res.setContentType("Content-type: application/RFC822");
              > res.setHeader("Content-Disposition", "attachment; filename=\"" +
              youfilename
              > + "\"");
              >
              >
              > This should solve your problem.
              >
              >
              > Kumar.
              >
              > Per Lovdinger wrote:
              >
              > > Hi all,
              > >
              > > This is the scenario I'm trying to achieve:
              > >
              > > - Display html page with a button or href "download csv file"
              > > - the user clicks
              > > - the file-download pop-up window should appear,so the user can save
              the
              > > file at any location
              > >
              > > This is how far I get:
              > > - when the user clicks a servlet gets activated
              > > - Servlet:
              > > - creates the csv file and write it to disk
              > > - now I want the servlet to do something so that the file-download
              window
              > > opens
              > >
              > > - I've tried with forward the request to the url (which only displays
              the
              > > content in the browser)
              > > - I write to HttpServletResponse it opens the file in excel which I
              don't
              > > want
              > >
              > > Any ideas ?
              > > Thanks in advance
              > > Per
              >
              

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • In a multiple monitor situation, how do I get popup windows to open on the same monitor as the parent application is displayed.

    I have two monitors. I have an application that I run all day, displayed on my secondary monitor. Whenever a popup windows is launched form that application, it always opens on the primary monitor. Very annoying. Any way to get the popup to launch in on the same monitor as the parent application?

    Did you solve this problem ?

  • Even though block popup windows is unchecked in content tab of options, I am still not getting any popups. Please help me.

    Hi - Even though block popup windows is unchecked in content tab of options, I am still not getting any popups. Please suggest how to over come this problem.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Did you make sure that your security software isn't blocking the pop-ups?
    Boot the computer in Windows Safe Mode with network support (press F8 on the boot screen) as a test.
    *http://www.bleepingcomputer.com/tutorials/how-to-start-windows-in-safe-mode/

  • SSO UIDPW not working for external Popup Window but works with SAPLOGONTICK

    Dear Experts,
    I have an issue with SSO user mapping (UIDPW), but the same scenario is working with SAPLOGONTICKET.
    Some list gets displayed in the Web Dynpro ABAP iView which has the hyperlinks where on click on the hyper link it opens a external popup window (another Web Dynpro Application) and display the summary some data.
    This scenario works when I set the logon method to SAPLOGONTICKET, but when I set it as UIDPW it won't work when a new window opens on click on the hyperlink from Web Dynpro iView as stated above. It asks to login to R/3 system.
    Can anyone please let me know what could be the reason it fails in External Popup window scenario when logon method as UIDPW.
    Thanks
    Murthy

    Hi Murthy,
    You can use application integrator iView to integrate your ABAP application into the portal and you'll be able to pass the variables <MappedUser>, <MappedPassword>, etc. assuming you know about the security risks in passing mapped info.
    http://help.sap.com/erp2005_ehp_05/helpdata/en/36/5e3842134bad04e10000000a1550b0/frameset.htm
    Still, your ABAPers might need to handle the passed in variables in the first ABAP application and pass them onto the second one.  Again, without knowing how you navigate between the 2 apps and other details about your system landscape, versions, etc. this remains as a guess.  If you search SDN, you'll find many different solutions then you can choose one which is most suitable for your situation.
    Regards,
    Dao

  • How to close main window on click of a button on popup window

    Hi All,
    I have created a web page which on certain condition display a popup window to to provide information. Wht i want is that when i click on close button on my popup window, my main window should also close.
    Can anyone please help with this requierment!!!
    Regards,
    tushar

    Hi All,
    Could anyone of you please help me by answering the thread
    WDDOEXIT method not called when the application is closed from the portal
    Thanks,
    Subash M

  • How to disable parent window while popup window is coming

    Hi,
    I am working on Oracle Applications 11i.
    I am able to get the popup window using the Java script in the controller.
    Please see the below code for the reference.
    String pubOrderId = pageContext.getParameter("orderId");
    StringBuffer l_buffer = new StringBuffer();
    StringBuffer l_buffer1 = new StringBuffer();
    l_buffer.append("javascript:mywin = openWindow(top, '");
    l_buffer1.append("/jct/oracle/apps/xxpwc/entry/webui/AddAttachmentPG");
    l_buffer1.append("&retainAM=Y");
    l_buffer1.append("&pubOrderId="+pubOrderId);
    String url = "/OA_HTML/OA.jsp?page="+l_buffer1.toString();
    OAUrl popupUrl = new OAUrl(url, OAWebBeanConstants.ADD_BREAD_CRUMB_SAVE );
    String strUrl = popupUrl.createURL(pageContext);
    l_buffer.append(strUrl.toString());
    l_buffer.append("', 'lovWindow', {width:750, height:550},false,'dialog',null);");
    pageContext.putJavaScriptFunction("SomeName",l_buffer.toString());
    But here the problem is, even though popup window is there, i am able to do the actions on the parent page.
    So how to disable the parent page, while getting the popup window.
    Thanks in advance.
    Thanks
    Naga

    Hi,
    You can use javaScript for disabling parent window as well.
    Refer below link for the same:
    http://www.codeproject.com/Questions/393481/Parent-window-not-disabling-when-pop-up-appears-vi
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • RE: Getting multiple values from more than one multiple select popup window

    I have a button on a JSP of mine that when clicked creates a popup window (right now it is called popup.html) with a multiple select menu.
    My question is how do I get all the values selected from the menu into my JSP (sample.jsp) so that I can set each of the values for my bean.
    The other problem is that I have more than one select multiple menu.
    Please help if you can. Any advice or suggestions here would be greatly appreciated!
    Thank you!

    I realize that I can use request.getParameterValues to get the values selected from my html because I am passing them to the hidden inputs I have and then using the request.getParameterValues to get each of the values.
    MY PROBLEM IS WHAT IF I HAVE 4 MULTIPLE SELECTS??? How can I use the same html popup menu to get the values from the 4 different multiple selects????
    I look forward to your response.
    This code is from my JSP:
    <INPUT TYPE="TEXT" NAME="Field1" SIZE="15">
    <INPUT TYPE="hidden" name="F1Rad1">
    <INPUT TYPE="hidden" name="Permission">
    <input type=button name=choice onClick="window.open('optionPicker.html','popuppage','width=250,height=100');" value="Options"></TD>
    Here is my optionPicker.html code for the pop up menu:
    <html>
    <head>
    <script language="JavaScript">
    function sendValue(s)
    var boxSize= s.options[0].value;
    var restrict     = s.options[1].value;
    window.opener.document.addNewForm.F1Rad1.value = boxSize;
    window.opener.document.addNewForm.Permission.value = restrict;
    window.close();
    </script>
    </head>
    <body>
    <center>
    <form name=selectform>
    <select multiple name=selectmenu size="2">
    <option value="large">Large Text Input Area
    <option value="restrict">Restricted Access
    </select>
    <p></p>
    <input type=button value="Select Option(s) For Field" onClick="sendValue(this.form.selectmenu);">
    </form>
    </center>
    </body>
    </html>

  • How to pass the values from popup window to parent's window

    Hi Experts,
    in my application i need to develop one popup window in that i have created 4 dropdowns and one ok button , if i willl click on that ok  button the values should pass to parent window dropdownlistboxes
    can any body suggest how i will get the popup window values
    thanks in advance,
    ramani.

    Hi Ramani,
    I can provide few inputs on how can we control JSP 2 from JSP1.
    Here is the code. Check if you can convert this to make useful to you. I am not passing values but control.
    here it is:
    JSP 1.
    <h1>Page One</h1>
    <br>
    <a href="/irj/portalapps/<PAR_FILE_NAME>/images/<HTML_PAGE_NAME>.html#part1">part 1</a>
    <br><br><br>
    <a href="/irj/portalapps/<PAR_FILE_NAME>/images/<HTML_PAGE_NAME>#part2">part 2</a>
    <br><br><br>
    <a href="/irj/portalapps/<PAR_FILE_NAME>/images/<HTML_PAGE_NAME>#part3">part 3</a>
    JSP 2.
    <h1>Page Two</h1>
    <br>
    <a name="part1">
    <h3>Part 1</h3>
    </a>
    <a name="part2">
    <h3>Part 2</h3>
    </a>
    <a name="part3">
    <h3>Part 3</h3>
    </a>
    This way you can move from one JSP to other.
    regards
    -Kedar Kulkarni
    reward points if useful.
    Message was edited by:
            Kedar Kulkarni

Maybe you are looking for

  • Mini DVI to DVI monitor Kernal Panic

    I have a 20" iMac Intel Core Duo, mini DVI to DVI-D adapter, cable, and Princeton 17" DVI-D monitor. When I hook up the monitor to the iMac I immediately receive a Kernal Panic. If I restart, it also results in a Kernal Panic. It does not matter if t

  • Adobe Acrobat 9 Pro icons on desktop look strange

    My PDFs on my Windows 7 desktop no longer are the red/white icons.  They now are black/white and I believe it shows the first page of the doc.  How do I fix?  Thanks.

  • Disable Photo downloader in photoshop album starter 3.0

    When I connect my camera via USB, the photo downloader starts & ties up the camera software. Other forum topics instruct to choose edit / preferences / camera or card reader & deselect "use Adobe photo downloader to get photos from camera or reader",

  • Storyboard Views Disappear in Xcode 6.1

    Hi, I am learning IOS programming with Xcode and is a rookie for all practical purposes so please bear with me. I am taking an online course and following their programming video instructions using an older version of Xcode. There are 2 issues that I

  • Is Jolt part of Tuxedo?

    Our company is using Tuxedo and looking into some web based applcations using XML to communicate with the services. My question is, is Jolt part of Tuxedo in which it can be used without additional cost? What are ballpark figures to get the Jolt Serv