Jsp page automatically running my javascript code

I have some javascript functions in my jsp that I don't want to run until some kind of action occurs like an onclick event or a button push, but when the page loads it is executing the function. Is there any way to stop this?

Normally a Javascript is processed as it is read by the browser, anything that appears inside of a function will not be processed unless that function is called in the normal reading sequence. It is generally a good practice to keep your callable functions inside of the <head> </head> tags. If you believed that your function got executed when the page loads, check the <body> tag to see if it includes an onLoad event-handler that might have triggered the execution or else the function may have been unintentionally called.
The following HTML file demonstrates:
1) How a JavaScript function is called by the browser in the process of rendering the page,
2) How you can trigger a call to a JavaScript function as soon as the page is loaded (via a body onLoad), and
3) How a JavaScript function can be called after the page has been rendered (via a hyperlink)
<html>
<head>
<script>
var zzz="disp function is called from a hyperlink";
function disp(text) {
   alert(text);
</script>
</head>
<body onLoad="disp('disp function is called after the document has been loaded')">
Click me
<script>
alert("disp function is called in the course of reading the HTML");
</script>
</.body>
</html>V.V.

Similar Messages

  • Getting Exception: @Scratchpad/1:1 exception while running simple javascript code in mozilla scrachpad

    getting Exception: "@Scratchpad/1:1 exception" while running simple javascript code in mozilla scrachpad

    Does this also happen if you run the code in the Web Console (Firefox/Tools > Web Developer)?
    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

  • Error while running a jsp page : "jasper run time error"

    hii
    I'm facing trouble while running some jsp page . the error is as follows:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK
         org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
         org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
         org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    Apache Tomcat/5.0.28
    The set up in my system (path set up is as follows):
    Catalina home: C:\ apache software foundation\Tomcat 5.0
    Classpath: %java_home%;C:\j2sdk1.4.2_03\bin;
    Javahome: C:\ j2sdk1.4.2_03\jre;
    path: C:\ j2sdk1.4.2_03\bin
    <there are other variables available in path, along with that I have added the j2sdk1.4.2_03\bin in path".
    So if u have any way out for it please let me know.

    I think you only need to add: c:\j2sdk1.4.2_01
    you have specified jre on the end of your path, it is not the jre that is required, but the jdk.
    If you are using startup.bat and shutdown.bat (or .sh on Linux) you can amend the files with a text editor (open the startup.bat in notepad), like so:
    @echo off
    set JAVA_HOME=c:\j2sdk1.4.2_01
    if "%OS%" == "Windows_NT" setlocal
    I this will start Tomcat with the correct settings, regardless of your environment settings.

  • How can i redirect to another JSP page automatically after some event

    I am developing a Tic-Tac-Toe game which can be played between two players who are on two different machines.
    When the first player comes to the Welcome page he will redirected to a Waiting Page when he clicks on the 'Start' button.
    When the second player comes to the Welcome page he will be redirected directly to the Game page, on clicking the 'Start' button.
    So how can i redirect the first player to the Game page after the second player is available for the game.
    And if i want to manage multiple instances of my game how can i do that//
    I am using JSP, javascript and MySQL for developing my project, and I am new to all these tools, but i would still like to carry on with all these only

    This is a bit of a challenge because of the nature of the web. Generally the web is "pull only" meaning that the browser has to initiate any interactions - the server can't push data to the browser if it wasn't asked to.
    The easiest way to solve this is using AJAX via JavaScript to periodically poll the server for any status changes. There are other ways (the Comet protocol is one) but they start to get a bit difficult and are still a bit new and not completely supported in a standards way. And to be honest they are still basically polling though in a more efficient way.
    Are you using a JavaScript framework? Most of the JavaScript frameworks that I've used have built in support for polling in the background. You'd have to have the JSP/servlet side be able to handle these polling requests from the browser and, when another person joins the game, the server indicates that and sends that back to the browser.
    As far as multiple instances I would have the server automatically pair up users as needed. So when the first player arrives he has to wait for another player. When the second player arrives a new game is created for those two players. Now a third player arrives and waits until a fourth player shows up. When player 4 joins another separate game is created. Presumably the conversation between the browser and the server will need to include a "game number" or other unique number so that the server can keep track of the games.

  • Javascript is not called in jsp page

    Hi,
    I have jsp page which actually redirect to another jsp page....
    I need to run some javascript code before redirecting to another page
    But it seems script got skipped & it goes to desired page
    code snippet:
    <%@ taglib uri="/ABCTaglib" prefix="AA" %><%response.setContentType("text/xml");%><AA:sitemap pagename="test" />
    <script type="text/javascript">
    alert("testing");
    </script
    String answerid = request.getParameter("answerid");
    String url = request.getParameter("url");
    response.sendRedirect(url);I am expecting an alert "testing" before redirect to another page.
    Thanks in advance

    Javascript is not java.
    Java/JSP runs on the server.
    javascript runs on the client, when the browser loads the page.
    As far as the server is concerned, all that javascript you have there is just template text to be echoed out in its response.
    A redirect will cancel the current response, and send a "redirect" response to tell the client where to go.
    Any output written to the response up until the redirect is discarded.
    If you want to pop up an alert, you actually have to return a response web page, with that javascript embedded in it, and then have that page navigate onwards to where you want to go (potentially using a meta refresh tag)

  • Displaying html code in JSP page

    Hi.
    How do I display HTML code in an jsp page, so that the actual code is printet on the screen
    fx:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

    I can't get my reply to show properly, but the answer is;
    Change < into &lt ; and > into &gt ;
    but with the semi-colons stuck next to the &lt and &gt if you get my drift

  • When a jsp page opened

    Hello everybody,
    I have a jsp page that includes personal_no and code areas. I want the mouse on personal_no item when this page is opened.
    Does any one have any idea?
    Thanks

    I dunno if I can get much more detailed than I did originally.
    the onLoad attribute runs when the form loads (duh!)
    <body onLoad="loadForm()">
    basically says that when the page loads, it should call the javascript function loadForm().
    The javascript function I defined was also fairly simple:
    <script language='javascript'>
    <!-- 
    function loadForm(){   
      document.forms[0].personal_no.focus(); 
    //-->
    </script>This is the javascript function loadForm and should be included in the <head> of you html/jsp page (whatever you are writing)
    It might need a little modification on your part - I was guessing as to the field name.
    the standard format is document.formName.controlName.focus
    where
    - formName is the name of your form
    - controlName is the name of your control (input type='text')
    If you had
    <form name="myForm">
    <input type="text" name="personal_no">
    </form>then the code could be
    "document.myForm.personal_no.focus()"
    This should put the cursor in the textfield personal_no on the form, so you can start typing without clicking in the field.
    If you are using IE, check the little icon in the lower left of the window. If it has a yellow exclamation mark, double click it to see what the javascript error is.
    jeez, thats a lot of explaining. Whether it clears things up, or just makes things more complicated, I dunno.
    But please try for more than 2 minutes before posting for help again :-)

  • Why JSP Script Always Run First...

    Hey' i don't understand about this code works, why when i run this page, it always print start in console before i click the button.
    This is my code :
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
            <script language="Javascript">
                function checkButton(){       
                    <%
                    /* This declaration will print in console
                     * every time the page load.
                     * it suppose to be print after i click the buttonCheck button. */
                        System.out.println("start");
                    %>          
            </script>
        </head>
        <body>
             <form name="myForm">
                   <input type="button" value="check" onClick="checkButton()" name="buttonCheck">
             </form>
        </body>
    </html>Why my JSP Script always run before i click the button? JSP script must be run after i click my button. is there any explanation about this?
    Thanks..
    Message was edited by:
    hudoq

    the jsp scriptlet tag will be execute while compilation.
    so all the scriplet tags will be compiled and
    executed while loading. This is generally not 100% true. JSP files will be compiled only once in the fresh server start. This also explains the "long loading time" on the 1st view ;) The subsequent views just executes the already compiled JSP.

  • How to retrieve multiple data from table and represent it in jsp page

    Hi
    The below JavaScript code is used to add row in the table when I want to add multiple row data into table for single entry no field.
      <html>  function addRow()
                i++;
                var newRow = document.all("tblGrid").insertRow();
                var oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='srno"+i+"' type='text' id='srno"+i+"' size=10>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='itmcd"+i+"' type='text' id='itmcd"+i+"' size='10'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='itmnm"+i+"' type='text' id='itmnm"+i+"' size='15'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='indentqty"+i+"' type='text' id='indentqty"+i+"' size='10'>";
                oCell = newRow.insertCell();
                    oCell.innerHTML = "<input name='uom"+i+"' type='text' id='uom"+i+"' size='10'><input type='hidden' name='mcode"+i+"'id='mcode"+i+"'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='packqty"+i+"' type='text' id='packqty"+i+"' size='10'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='packuom"+i+"' type='text' id='packuom"+i+"' size='10'><input type='hidden' name='pack"+i+"' id='pack"+i+"'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='rate"+i+"' type='text' id='rate"+i+"' size='10'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='dor"+i+"' type='text' id='dor"+i+"' size='0' onClick='"+putdate(this.name)+"'>";           
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='bccode"+i+"' type='text' id='bccode"+i+"' size='10'></td><input type='hidden' name='bcc"+i+"' id='bcc"+i+"'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='cccode"+i+"' type='text' id='cccode"+i+"' size='10'></td><input type='hidden' name='ccc"+i+"' id='ccc"+i+"'>";
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input name='remark2"+i+"' type='text' id='remark2"+i+"' size='20'>";           
                oCell = newRow.insertCell();
                oCell.innerHTML = "<input type='button' value='Delete' onclick='removeRow(this);' />";
               // oCell = newRow.insertCell();
               // oCell.innerHTML = "<input type='button' value='Clear' onclick='clearRow(this);' />";
            }<html>  Then this data are send to the next Servlet for adding into two table.
    My header portion data are added into one table which added only one row in table. while footer section data are added into the no of rows in another table dependent on No. of
    Rows added into jsp page.
    Here is an code for that logic.
    <html>
    ArrayList<String> mucode = new ArrayList<String>();
                                ArrayList<Integer> serials = new ArrayList<Integer>();
                                ArrayList<Integer> apxrate = new ArrayList<Integer>();
                                ArrayList<Integer> srname = new ArrayList<Integer>();
                                ArrayList<String> itcode = new ArrayList<String>();
                                ArrayList<String> itname = new ArrayList<String>();
                                ArrayList<Integer> iqnty = new ArrayList<Integer>();
                                ArrayList<String> iuom = new ArrayList<String>();
                                ArrayList<Integer> pqnty = new ArrayList<Integer>();
                                ArrayList<String> puom1 = new ArrayList<String>();
                               ArrayList<Integer> arate = new ArrayList<Integer>();
                                ArrayList<String> rdate = new ArrayList<String>();
                                ArrayList<String> bcs = new ArrayList<String>();
                                ArrayList<String> ccs = new ArrayList<String>();
                                ArrayList<String> remarkss = new ArrayList<String>();
                                //ArrayList<Integer> qtyrecs = new ArrayList<Integer>();
                                //ArrayList<String> dors = new ArrayList<String>();
                                //ArrayList<String> remarks = new ArrayList<String>();
                     String entryn = request.getParameter("entryno");       
                        String rows = request.getParameter("rows");
                        out.println(rows);  
                        //String Entryno = request.getParameter("entryno");
                       // out.println(Entryno);
                      int entryno = 0,reqqty = 0,srno = 0,deprequest = 0,rowcount = 0;
                                if(!Entryno.equals("")){
                                        entryno = Integer.valueOf(Entryno);
                                if(!rows.equals("")){
                                        rowcount = Integer.valueOf(rows);
                               for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("srno"+i)!=null){
                                                serials.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
                                                out.println(serials.size());
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("srno"+i)!=null){
                                                srname.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
                                out.println(srname.get(0));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("itmcd"+i)!=null){
                                                itcode.add(request.getParameter("itmcd"+i).trim());
                                        } //out.println(itcode.get(i));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("itmnm"+i)!=null){
                                                itname.add(request.getParameter("itmnm"+i).trim());
                                        }//out.println(itname.get(i));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("indentqty"+i)!=null){
                                                iqnty.add(Integer.valueOf(request.getParameter("indentqty"+i).trim()));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("uom"+i)!=null){
                                                iuom.add(request.getParameter("uom"+i).trim());
                                        }//out.println(iuom.get(i));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("mcode"+i)!=null){
                                                mucode.add(request.getParameter("mcode"+i).trim());
                               for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("packqty"+i).equals("")){
                                          pqnty.add(0);
                                        }else
                                            pqnty.add(Integer.valueOf(request.getParameter("packqty"+i).trim()));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("pack"+i)!=null){
                                                puom1.add(request.getParameter("pack"+i).trim());
                                       }else
                                        puom1.add("");
                               for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("rate"+i).equals("")){                                     
                                            arate.add(0);
                                        }else
                                        arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));   
                     /* for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("rate"+i)!=null){
                                                arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));
                              for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("dor"+i)!=null){
                                                try{
                                                        rdate.add(dashdate.format(slashdate.parse(request.getParameter("dor"+i).trim())));
                                                }catch(ParseException p){p.printStackTrace();}
                                        }else
                                           { rdate.add("");}
                                   for(int i=1;i<=rowcount;i++){
                                 if(request.getParameter("bcc"+i)!=null){
                                                bcs.add(request.getParameter("bcc"+i).trim());
                                        }out.println(bcs.get(0));
                                for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("ccc"+i)!=null){
                                                ccs.add(request.getParameter("ccc"+i).trim());
                                        }out.println(ccs.get(0));
                                for(int i=1;i<=rowcount;i++){
                                    out.println("remark2");
                                        if(request.getParameter("remark2"+i)!=null){
                                                remarkss.add(request.getParameter("remark2"+i).trim());
                                        }out.println(remarkss.get(0));
                        ArrayList<String> Idate = new ArrayList<String>();
                        for(int i=1;i<=rowcount;i++){
                                        if(request.getParameter("dateindent"+i)!=null){
                                                try{
                                                        Idate.add(dashdate.format(dashdate.parse(request.getParameter("dateindent"+i).trim())));
                                                }catch(ParseException p){p.printStackTrace();}
                    String Rdate = dashdate.format(new java.util.Date());
                     String tdate = dashdate.format(new java.util.Date());    
                     // String Indentdate = dashdate.format(new java.util.Date());
                   //  String ApprovedT1 = dashdate.format(new java.util.Date());
                   //  String ApprovedT2 = dashdate.format(new java.util.Date());
                       // String ApprovedT1=" ";
                        //String ApprovedT2="";*/
                    String ApprovedT1= dashdate.format(new java.util.Date());
                   out.println (ApprovedT1);
                      String ApprovedT2=dashdate.format(new java.util.Date());
                       out.println(ApprovedT2);
                    String Indentdate=(dashdate.format(slashdate.parse(request.getParameter("dateindent").trim())));
                       out.println(Indentdate);
                        String Cocode ="BML001";  
                        out.println(Cocode);
                        String Deptcode = request.getParameter("dept1");
                        out.println(Deptcode);
                        String Empcode = request.getParameter("emp");
                        out.println(Empcode);
                        String Refno =request.getParameter("rtype"); 
                         out.println(Refno);
                        String Divcode = request.getParameter("todiv1");
                        out.println(Divcode);
                        String Usercode = "CIRIUS";    
                         String Whcode = request.getParameter("stor");
                        out.println(Whcode);
                        // String Itemgroupcode = request.getParameter("");
                         String Itemgroupcode ="120000";
                         out.println(Itemgroupcode);
                        String Supplytypecode = request.getParameter("stype");
                        out.println(Supplytypecode);
                        String Delcode = request.getParameter("deliverycode");
                        out.println(Delcode);
                        String Itemclass="WS";
                        out.println(Itemclass);
                        // String Itemclass = request.getParameter("iclass");
                       // out.println(Itemclass);
                        String unitcode = request.getParameter("uni");
                        out.println(unitcode);
                         String Todivcode = request.getParameter("todiv1");
                        out.println(Todivcode);
                        String Appxrate = request.getParameter("rate");
                        out.println(Appxrate);
                        String Srno = request.getParameter("srno");
                        out.println(Srno);                
                    /*    String Indqty = request.getParameter("indentqty");
                      out.println(Indqty);*/
                  String Itemcode = request.getParameter("itmcd");
                       out.println(Itemcode);
                       String Othersp = request.getParameter("remark1");
                        out.println(Othersp);
                        String Reqdt = request.getParameter("dor");
                        out.println(Reqdt);
                        String Munitcode = request.getParameter("mcode");
                        out.println(Munitcode);
                        String Packqty = request.getParameter("packqty");
                        out.println(Packqty);               
                        String Packuom = request.getParameter("pack");
                        out.println(Packuom);
                        String Remark2 = request.getParameter("remark2");
                        out.println(Remark2);
                        String BC = request.getParameter("bcc");
                        out.println(BC);
                        String CC = request.getParameter("ccc");
                        out.println(CC);
                        try{
                            st=connection.createStatement();
                            connection.setAutoCommit(false);
                            String sql="INSERT INTO PTXNINDHDR(COCODE,DEPTCODE,EMPCODE,APPROVEDT1,APPROVEDT2,INDDT,ENTRYNO,REFNO,REMARKS,DIVCODE,USERCODE,WHCODE,ITEMGROUPCODE,SUPTYPECODE,DELCODE,UNITCODE,TODIVCODE,ITEMCLASS)VALUES('"+Cocode+"','"+Deptcode+"','"+Empcode+"','"+ApprovedT1+"','"+ApprovedT2+"','"+Indentdate+"',"+Entryno+",'"+Refno+"','"+Othersp+"','"+Divcode+"','"+Usercode+"','"+Whcode+"','"+Itemgroupcode+"','"+Supplytypecode+"','"+Delcode+"','"+unitcode+"','"+Todivcode+"','"+Itemclass+"')";
                            out.println(sql);
                            st.addBatch(sql);
                            for(int i=0;i<serials.size();i++){
                                out.println("Inside the Statement");
                                String query3="test query for u";
                                out.println(query3);
                               String queryx="Insert into PTXNINDDTL(APXRATE,ENTRYNO,BRKNO,INDQTY,ITEMCODE,OTHERSPFCS,MUNITCODE,PACKQTY,PACKUOM,REMARKS,DIMSUBGRPCODE,DIMCODE,REQDT)VALUES("+arate.get(i)+","+entryno+","+srname.get(i)+","+iqnty.get(i)+","+itcode.get(i)+",'"+Othersp+"','"+mucode.get(i)+"',"+pqnty.get(i)+",'"+puom1.get(i)+"','"+remarkss.get(i)+"','"+bcs.get(i)+"','"+ccs.get(i)+"','"+rdate.get(i)+"')";
                               out.println(queryx);
                                st.addBatch(queryx);
                           int[] result=st.executeBatch();
                           connection.commit();
                           for(int k=0;k<result.length;k++)
                           out.println("rows updated by "+(k+1)+"insert sta:"+result[k]+"");
                        catch(BatchUpdateException bue)
                        out.println("error1;"+bue+"");
                        catch(SQLException sql)
                        out.println("error2;"+sql+"");
                        catch(Exception l)
                        out.println("error3;"+l+"");
    </html>
       Now I looking for to retrieve this footer section data available in multiple rows from footer table and present it in jsp page .
    I am finding difficulties in how to show this multiple row data for dynamic no of rows .i.e. variable no. of rows.
    I have able to show the data in Header portions of page in this ways
    here i am adding the part of code which shows the data from header part of table i.e from Header table
      <html>
    <h2 align="center"><b>Indent Preparation</b></h2>
        <div align="left">
            <table width="849" border="0" cellspacing="3" cellpadding="3" align="center">
                <tr>
                    <td ><div align="left"><b>Indent No.</b></div></td>
                    <td ><label>
                            <input name="indentno" type="text" id="indentno" size="15" value="" /><input type="hidden" name="no" id="no">
                    </label></td>
                    <td ><div align="center"><strong>Indent Date</strong></div></td>
                    <td ><label>
                            <div align="center">
                                <input name="dateindent" type="text" id="dateindent"value="<%=date1%>"/><input type="hidden" name="no" id="no">
                            </div>
                    </label></td>
                    <td> </td>
                    <td><div align="right"><strong>Entry No.</strong></div></td>
                     <%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
            <td><input type="text" value="<%=hdrcode.get(3)%>" size="10"></td>
    <%}else{%>
                   <td><input type="text" name="entryno" id="entryno" value="<%=entryNo%>"/></td>
                             <%}%>
                            <div align="right"></div>
                </tr>
                <tr>
                    <td><b>Division</b></td>
                    <%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
    <td><input type="text" value="<%=hdrdetails.get(9)%>" size="20"</td>
    <td><input type="hidden" name="div1" id="div1" value='<%=hdrcode.get(10)%>'></td>
    <%}else{%>
                   <td><input type="text" name="div" id="div" /></td>
                   <td><input type="hidden" name="div1" id="div1" /> </td>
              <%}%>
                    <td> </td>
                    <td> </td>
                    <td><div align="right"><strong>Unit</strong></div></td>
                   <%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
    <td><input type="text" value="<%=hdrdetails.get(14)%>" size="20"</td>
    <td><input type="hidden" name="uni" id="uni" value='<%=hdrcode.get(12)%>'></td>
    <%}else{%>
                   <td><input type="text" name="unit" id="unit" /></td>
                   <td><input type="hidden" name="uni" id="uni" /> </td>
              <%}%>
                </tr>
                <tr>
    </html>
      Any suggestion on any above works is highly appreciated.
    Thanks and regards
    harshal

    Too much code. It's also not well intented nor formatted. I don't see a question either or it got lost in that heap of unformatted code.
    I will only answer the question in the thread's subject:
    How to retrieve multiple data from table and represent it in jsp pageTo retrieve, make use of HttpServletRequest#getParameterValues() and/or #getParameter().
    To display, make use of JSTL's c:forEach.

  • How to call a concurrent program from a Custom JSP page.

    Hi,
    I have a custom JSP page which i have deployed by creating a form function with the path of the JSP Page
    and added the JSP Page to the OA_HTML top.
    Now, i need to call a concurrent program from the JSP Page, i have all the parameters in my page and i am using the standard class as below:
    ConcurrentRequest cr= new ConcurrentRequest(con);
    int requestId= cr.submitRequest("XXINV",programName,null,null,false,vec);
    I have verified my connection object and it is OK but i am getting the exception that user is not set to run the program.
    I tried the below code in my JSP page and getting -1 for all test variables :-
    int userId = wctx.getUserId();
    int respApplId = wctx.getRespApplId();
    int respId = wctx.getRespId();
    I think i need to set the context in JSP page to run the program..
    Pls help ....
    Regards
    Saurabh Jaiswal

    Hi,
    Thanks for the reply,,,
    This is a possible solution but this will allow to run the program anyhow.
    But the procedure which i call thru callable statement will start with
    fnd_global.apps_initialize (3825, 50603, 704);
    fnd_request.submit_request API call.
    Now, the values of user and Responsibilty is required in the program and it changes.
    With this approach we have to hardcode the user and resp.
    The same JSP page is attached to other responsibilities and there the concurrent program would get fired as if fired from the resp Id hardcoded as above.
    Need to capture user Id and RespId.
    How can i set the apps Context in JSP page???
    Regards
    Saurabh Jaiswal

  • How to redirect a jsp page?

    Hi
    I have two jsp pages called submit.jsp and save.jsp.In the submit.jsp page
    I wrote the following code
    <form name= Submit action=save.jsp>
    <input type=Submit name=save value=save>
    whn i submit save .jsp page is opend and will dispaly a message saved the data.Now wht i want is after the save.jsp page is opened the page should be automatically redirected in 3 seconds to submit.jsp that is the first page.How can i dothis.Pls give me some code.
    Thanks

    Something like...
    <META HTTP-EQUIV="Refresh" CONTENT="3; URL=your.jsp">
    in your <head> tag where 3 is the number of seconds to wait.

  • How to use extends attribute in jsp page directive

    Can anybody tell how to extend a existing .jsp file from another .jsp file. I have tried but it gives error.
    I have used Extends attribute of page directive as below:
    <%@ page extends = "MyAnotherJsp.jsp"%>
    I also tried : <%@ page extends = "MyAnotherJsp"%>
    I am using Tomcat as a web server
    Also tell where to put those files.
    Thanks.

    Hi I am using Netbeans 5.5, Sun Java System Application Server 9.
    ABC.java
    package javapackage;
    public class ABC{
    public String show(){
    return "Sandip Gaikwad";
    index.jsp
    <%@ page extends="javapackage.ABC" %>
    <html>
    <head>
    <title>JSP Page</title>
    </head>
    <body>
    <h1>JSP Page </h1>
    </body>
    </html>
    Above code throws following exception at runtime:-
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    Server log
    StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,<nulltype>,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:94)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:384)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:461)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:528)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:412)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:318)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    If I delete the line <%@ extends="javapackage.ABC"%> it works fine. Please tell me what is wrong with this line.

  • PLEASE HELP!!! using servlet to generate an image in jsp page

    Hi,
    I am so stuck on this... please help.
    I have a servlet that generated a gif image dynamically. It uses a bean that stores the gif image in a byte array.
    The servlet outputs the byte data to the output stream. The code is really simple and looks like this:
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //HttpSession session = request.getSession();
            try {
                ServletOutputStream stream = response.getOutputStream();
                ImageByteInformation imageByteInfo = (ImageByteInformation) request.getAttribute("imageByteInformation");
                response.setContentType("image/gif");
                response.setContentLength(imageByteInfo.getByteData().length);
                stream.write(imageByteInfo.getByteData(), 0, imageByteInfo.getByteData().length);
                stream.flush();
            }catch( Exception e){   
                System.out.println("You are hooped!: " + e.getMessage() + " " + e.toString());           
            }When I redirect from the dispatch servlet straight to this servlet an image shows up in the browser window.
    However when I try to use this jsp page to display the image nothing happens...
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h2>Hello World!</h2>
            <img src="servlets/Map24ImageDisplayServlet"/>
             //I also tried src/servlets/Map24..., /src/servlets/Map24..., /display, servlets/display
            <h2>Did you see the image?</h2>
        </body>
    </html>My web.xml is here if it helps...
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <display-name>HelloProject</display-name>
    <servlet>
        <display-name>ServletDispatcher</display-name>
        <servlet-name>ServletDispatcher</servlet-name>
        <servlet-class>servlets.ServletDispatcher</servlet-class>
      </servlet>
      <servlet>
        <display-name>Map24ImageDisplayServlet</display-name>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <servlet-class>servlets.Map24ImageDisplayServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ServletDispatcher</servlet-name>
        <url-pattern>/hello</url-pattern>
      </servlet-mapping>
      <error-page>
        <error-code>404</error-code>
        <location>/404_error.html</location>
      </error-page>
      <servlet-mapping>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <url-pattern>/display</url-pattern>
      </servlet-mapping>
    </web-app>I can never get an image to come up. In fact I can never get the jsp page to run the servlet at all! HELP!!! What am I doing wrong?
    Thanks
    Edited by: Kind_of_Green on May 5, 2008 3:55 PM
    Edited by: Kind_of_Green on May 5, 2008 4:00 PM

    OK... so you WERE absolutely right about the src path for the image tag.
    However I also had another problem that was quite a bit more insidious and mostly just a symptom
    of how little I know about what goes on under the hood of a web app.
    My bean storing the image info was stored as a request attribute. When the servlet was called from the
    jsp page the request object was either reset or just never initialized. Anyway it is not the same request
    object I assumed it was being passed in the doGet method. I added my bean as a session
    attribute and everything is sparkly :)
    I can only assume that when a request is neither forwarded nor included (as is the case with
    calling the servlet from the img tag) it is disappeared.
    Anyway, thanks a mint man. I so totally appreciate your time.
    Ciao :)

  • Problem while i am sending image as a stream between jsp pages

    Hi,
    I want to send the image from one jsp page to another jsp via stream.
    Help to continue the process...

    Thak you for ur reply.
    But in Servlet-Chaining concept, one servlet output stream passed to another servlet and goes on...
    like that, is possible to do same in jsp.
    My actual task is to send the image from one jsp page to another, the sample code i paste here
    <%@ page import="java.io.*" autoFlush="true" %>
    <%
    System.out.println("======Send.jsp=====");
               ServletContext sercon = getServletContext();
                 String filename = sercon.getRealPath("/logo.png");
         RequestDispatcher rd = sercon.getRequestDispatcher ( "/read.jsp" ) ; 
         InputStream file=new BufferedInputStream(new FileInputStream(filename));
         int i,j=0;
                      try
              OutputStream os=response.getOutputStream();
              while((i=file.read())!=-1)
                   j++;
                   os.write((byte)i);
    System.out.println("Bytes Read : "+j);
         rd.forward(request,response);
              os.flush();
              file.close();
         catch(Exception e)
              System.out.println("Error"+j);
    %>
    <%@ page import="javax.swing.*,java.io.*,java.util.*"%>
    <%            
         byte[] by;
         int i,j=0;
    System.out.println("======Read.jsp=====");
         response.setContentType("image/png");
         InputStream is=request.getInputStream();
    System.out.println("In Read.jsp read bytes : "+is.available());
         ByteArrayOutputStream os=new ByteArrayOutputStream();
         while((i=is.read())!=-1)
              j++;
              os.write(i);
         by=os.toByteArray();
         out.println(by+"\n"+i);
         os.close();
         is.close();
    %>If i run this code (send.jsp) the image is displayed in the current page itself, and not forward to read.jsp
    Is any other alternative solutions then point out.

  • Embeding audio player in jsp page.

    Hello All,
    I have embed the quickTime player in a jsp page. Following is my code snippet of the object embedding.
    When I run the project my programme download and save the amr file from my database in the specified project location("../image/"+recordId +".amr"), but not run the amr file. Only logo of the player is displayed. Next Time when i run the project again, the amr file run smoothly. Probabely the problem is, when the programme run first time it could not find the required amr file location.
    My requirement is, after click a button, it will download the amr file in specific location and then read the file from that path. The file download successfully before embedding the object, but do not run the file.
    Also, the programme could not run the amr file from other than the project location. I am new in developing the jsp page, where amr file have to be play directly from the page. How can i solve the problem?
    any idea, please help.
    Code snippet:
    <% String recordId = request.getParameter("pId");
    String path=null;
    path="../image/"+recordId +".amr";
    %>
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="50" height="50" standby="Data is loading..." codebase="http://www.apple.com/qtactivex/qtplugin.cab">
    <param name="src" value=<%=path%>>
    <param name="autoplay" value="false">
    <param name="controller" value="true">
    <embed src=<%=path%> width="75" height="50" scale="1" autoplay="false" controller="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/">
    </embed>
    </object>

    uhr wrote:
    When I run the project my programme download and save the amr file from my database in the specified project location("../image/"+recordId +".amr")Why are you copying the file from DB to disk file system? This makes no sense, you're only duplicating the bytes and adding unnecessary overhead. Either keep it entirely in the DB, or just keep it at the disk file system and have the file attributes only in DB.
    but not run the amr file. Only logo of the player is displayed. Next Time when i run the project again, the amr file run smoothly. You apparently did not close the file outputstream after write.
    My requirement is, after click a button, it will download the amr file in specific location and then read the file from that path. The file download successfully before embedding the object, but do not run the file.
    Also, the programme could not run the amr file from other than the project location. I am new in developing the jsp page, where amr file have to be play directly from the page. How can i solve the problem?By closing the streams/resources properly.
    Code snippet:Comment: scriptlets are bad. You should use taglibs/EL.

Maybe you are looking for

  • Macbook pro mid 2014 (Magnet issue)

    Hi guys I have a macbook pro retina mid 2014 15", I've had this macbook pro for about 2 months and just yesterday i noticed a vibration/buzzing sound whilst on my lap on top of my macbook sleeve case, i noticed it made this noise when it was near the

  • Error While Creating Remittance Challan

    Dear All I have made down payment to a Vendor of Rs. 10,000 .TDS @11.33 was deducted on the Down Payment. Then he raised an invoice of Rs. 100,000. Again TDS was deducted on the Rs. 90,000 balance amount. Now when I am  Cretaing  Remittance Challan f

  • 2 iPhones, 1 iTunes Account, and 1 or 2 iCloud Accounts???

    I have 2 iPhone 4, a Macbook Pro, Macbook, Mac Mini, and Apple TV.  I am trying to setup the 2 phones to share to same iTunes account, contacts, and calendars.  However, I need each device to have different apps and backup to iCloud. Can i use 2 diff

  • HT5312 How to rescue my security question

    How to rescue my security question

  • How are Travelex Payment Method handled in AP?

    Hi I would like to know if there are any Outbound/Inbound extracts related to Travelex? Thanks Ranjani