Problem with onload in jsp page

Hi all,
I had two jsp pages, a search and a results page. I need to enter some search criteria in the first page and based on that criteria i will be getting the results in the results jsp. Now, when i click the back button in the results page, i need to go to the search page and the values which i entered in the search page needs to be present there. But the problem is i had a javascript function which runs on loading of the search page. This function will set all the values in this search page to empty whenever we go to the search page. I am calling this javascript function as follows in my search jsp page.
<body onload="setdefaultvalues('<%=name%>');">
I am having the code for the back button in the results page as follows.
<INPUT TYPE="button" VALUE='Back' onClick="javascript:history.go(-1);resetvalue(name);" class="button">
The problem i am facing is whenever i go to the search page by clicking on the back button, the values in the search page are getting empty because of the onload method. There is no way that i can remove this onload method as i require it for setting the values in the search page evrytime i get to that from other modules as it is the main page for my module. So, is there anyway that i can stop this function from executing when i come from the results page or is there any other way that i can store the values in the search page when going from the results page.

i think you really should have the result page include your search page contents rather than having the user need to click back as you'll end up with all sorts of nightmares in caching & session object management to be honest. if the search page is complex use javascript to hide contents and let the users expand them when they want to re-search.
however, if you feel you must i would suggest the following:
in your result page:
session.setAttribute("userQuery","true"); (you probably actually want to put a container object with the query information in here)
in your search page you could have something like:
<body <% session.getAttribute("userQuery")==null { %>onload="setdefaultvalues('<%=name%>');"<% } %>>
-or-
<body onload="setdefaultvalues('<%=name%>',<%=session.getAttribute("userQuery")==null?"true":"false"%>);">
function setdefaultvalues(name,run) { if ( !run ) return;....}
you'll have to decide when to remove the object though cause once its set its there until the session expires or you remove it.
hope that helps, good luck!

Similar Messages

  • Problems with filters and jsp pages.

    I have the following simple filter that checks if there is user information in the session object and redirects accordingly:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginFilter implements Filter
         public void init(FilterConfig filterConfig) {}
         public void destroy() {}
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
         throws IOException, ServletException
              System.out.println("filter");
              HttpSession session = ((HttpServletRequest)request).getSession();
              String action = request.getParameter("action");
              if(action != null && !action.equals("login") && !action.equals("wronglogin"))
                   if(session.getAttribute("username") == null)
                        ((HttpServletResponse)response).sendRedirect("index.jsp?action=wronglogin");
                        System.out.println("User not OK, kicking out...");
                   else
                        chain.doFilter(request, response);
                        System.out.println("User OK, letting in...");
              else
                   chain.doFilter(request, response);
    }The filter is mapped to an admin page with the name index.jsp. However, I get an error for every <% and %> tag in the file (there are quite a few) when I use the filter with the page. The page works fine without the filter, and the filter seems to work with pages without scriptlets (without the <% and %> tags). Here is the beginning of the error report:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, AnnotationName expected instead
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, delete these tokens
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    Jasper gives me many errors per <% and %> tag. As you can see there is a <% tag on line 6. Any idea, why this does not work?
    Thanks!
    Message was edited by:
    chincillya

    What is the JSP scriptlet code at line 6 ?
    By looking at the code we can identify if there are any syntax errors, otherwise we can't really guess what might be the problem.

  • Problem with JavaBeans in JSP.IT'S URGENT!!!

    Hi, i have problems with JavaBeans in JSP.
    In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
    <jsp:useBean id="paramBean" class="licentza.ParamBean" />
    <jsp:setProperty name="paramBean"
    property="nume"
              value='<%= request.getParameter("numeUser") %>' />
    where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
    And i get this error:
    Generated servlet error:
    D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
    ParamBean paramBean = null;
    What is the problem?Thank you.

    Hi,
    Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
    Rajesh

  • Problem with direction in a page(??????)

    Hi every body,
    I have a problem with direction in some page when i change the language to Arabic(right to left language).
    in some page like welcome page its completely true ,but in some page that i buile with my self (and add some portlet to it like :advanced search portlet)its directon does not appear properly,the label is appear in left, and text box appear in right(its not true).
    what can i do??????????????????
    please answer me :(

    This is not the right forum for your question. Try to post it in the Oracle Application Server Portal forum, or contact Oracle Support.
    Peter

  • Hi, I'm having problems with viewing a web page created with Adobe Muse CC latest release, I followed the various guides provided by Adobe, but the problem persists. The problem especially concerns the distorted display (the contents do not fit on the pag

    Hi, I'm having problems with viewing a web page created with Adobe Muse CC latest release, I followed the various guides provided by Adobe, but the problem persists. The problem especially concerns the distorted display (the contents do not fit on the page, so it suits size automatically) to a mobile web page to be displayed not on a normal browser, but in a WebView.

    Hi, I'm having problems with viewing a web page created with Adobe Muse CC latest release, I followed the various guides provided by Adobe, but the problem persists. The problem especially concerns the distorted display (the contents do not fit on the page, so it suits size automatically) to a mobile web page to be displayed not on a normal browser, but in a WebView.

  • Really having problems with organising documents in pages. For example, deleting pages deletes the whole section and I cannot insert a section break as its greyed out & sending an object to background deletes several pages - what the **** is going on???

    Really having problems with organising documents in pages. For example, deleting pages deletes the whole section and I cannot insert a section break as its greyed out & sending an object to background deletes several pages and trying to insert a text box autmatically creates new pages- what the **** is going on??? Is this programme really this badly thought out? I thought everything apple was supposed to be intuitive!?!?!? Help.

    You can not insert a section break into a textbox.
    You appear to have a lot of objects with wrap set, that once you take them out of the flow of text (by sending them to the background) causes the text to reflow and contract into fewer pages. Pages is almost unique in the way it forms up pages in Word Processing mode only so long as there is text on them.
    I suspect you probably have hammered away at returns, spaces and tabs as well to position things, which only works to add to the mess.
    Download the Pages09_UserGuide.pdf available under the Help menu and swot up a bit on how it works.
    You may find this a usueful resource as well:
    http://www.freeforum101.com/iworktipsntrick/
    Peter
    PS There is quite a lot of programming in OSX that is far from "intuitive". Pages is easy at one level, when using the templates, otherwise it can be quite frustrating.

  • Problem with JNDI and JSP in Tomcat

    Hi,
    Basically, what I've done is to use the Tomcat administration web
    application to create the DataSource, which looks like it populated the
    server.xml (see below). I then try to access the testconn.jsp, and am
    getting that "Name java:comp is not bound in this Context" error.
    I was wondering if anyone could tell me what I'm doing wrong?
    Thanks,
    Feri
    My Configuration:
    - Tomcat 5.0.19
    - MySQL 4.0.18-nt
    - mysql-connector-java-3.0.15-ga-bin.jar
    server.xml:
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    <!--Feri test JNDI-->
         <Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
              <Resource name="jdbc/injury" auth="Container"
    type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="jdbc/injury">
         <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>root</value>
    </parameter>
         <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
         <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/injury</value>
    </parameter>
         <parameter>
              <name>maxIdle</name>
              <value>30</value>
         </parameter>
         <parameter>
              <name>maxActive</name>
              <value>10</value>
         </parameter>
         <parameter>
              <name>maxWait</name>
              <value>10000</value>
         </parameter>
    </ResourceParams>
         </Context>
    <!--Feri test JNDI end-->
    </GlobalNamingResources>
    \webapps\injury\WEB-INF\web.xml:
    <resource-ref>
    <description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
    <res-ref-name>jdbc/injury</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    \webapps\injury\testconn.jsp
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.*" %>
    <%@ taglib prefix="ct" uri="/injury" %>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <h1>Connection test</h1>
    <ct:connection name="jdbc/injury">
    <%
    Statement stmt= conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("select * from user");
    while (rs.next()){
    %><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
    rs.close();
    stmt.close();
    %>
    </ct:connection>
    ConnectionTag.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.naming.*;
    import javax.sql.*;
    import javax.sql.DataSource;
    public class ConnectionTag extends TagSupport implements TryCatchFinally {
    private Connection conn;
    // JNDI name of the connection
    private String name;
    public void setName(String name)
         this.name = name;
    public int doStartTag()
         throws JspException
         try {
         Context env = (Context) new InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup(name);
         if (ds != null)
              conn = ds.getConnection();
         } catch (Exception e) {
         throw new JspException(e);
         if (conn == null)
         throw new JspException("can't open connection " + name);
         pageContext.setAttribute("conn", conn);
         return EVAL_BODY_INCLUDE;
    public void doCatch(Throwable t)
         throws Throwable
         throw t;
    public void doFinally()
         try {
         Connection conn = this.conn;
         this.conn = null;
         pageContext.removeAttribute("conn");
         conn.close();
         } catch (Exception e) {
    Tomcat 5.0\conf\Catalina\localhost\injury.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
    cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
    mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
    <Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
    </Context>

    Hi,
    First of all, you can find alot of information about this in the forum about jsp's.
    I think a good thing to do is not to put your context tag directly into the server.xml file.
    What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
    I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
    anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
    good luck

  • Problem with Sessions in JSP

    Hi,
    I am working on a JSP based website, where I am facing problem with sessions. The user is asked to login by providing her id and password. If found correct, a bean is created and populated with all her details and placed in session scope. I plan to use the information stored in the bean on other related pages until she logs out.
    <jsp:useBean id="validUser" scope="session" class="UserBean" >
    <c:set target="${validUser}" property="userId" value="${fn:trim(dbValues.UserId)}" />
    <c:set target="${validUser}" property="userName" value="${fn:trim(dbValues.UserName)}" />
    </jsp:useBean>
    <c:redirect url="userHome.jsp" /> The user is presented her homepage - 'userHome.jsp', where she can find various links, like 'Update Profile', 'Pay Registration Fees', 'Book Room' etc. The information stored in the bean is available on 'userHome.jsp'page.
    <A HREF='userHome.jsp'>Home</A>
    <A HREF='editPersonal.jsp'>Update Profile</A>
    <A HREF='registrationFee.jsp'>Pay Registration Fees</A>
    <A HREF='bookRoom.jsp'>Book Room</A>
    <A HREF='logout.jsp'>Logout</A> The problems are:
    1. Whenever user clicks on any of the above mentioned links and moves to any page, the bean comes out as null.
    <%-- Verify that the user is logged in --%>
    <c:if test="${validUser == null}">
    <jsp:forward page="loginForm.jsp">
    <jsp:param name="origURL" value="${pageContext.request.requestURL}" />
    <jsp:param name="errorMsg" value="You must be logged in to access this site." />
    </jsp:forward>
    </c:if> 2. The URL shows an additional jsessionid, which my client doesn't want to see.
    3. On every click on any link, the value of this jsessionid changes.
    What I presume, when I am clicking on different links, my session changes, and so I am seeing a different jsessionid. And since session is changing, therefore the bean is not available in a different session.
    All this works fine with localhost, problem comes into picture, when I upload my pages to the server.
    Puzzled, can anyone help, where am I going wrong? Let me add here, I am new to JSP and hence don't have much resources with me.

    There are several ways sessions can be exchanged between the browser and the server in a j2ee web application.
    1. The default is through cookies. However when the client does not accept cookies, the server appends the session id to the url.
    2. Some servers also facilitate session information exchange using session id in the url even if the client does accept cookies. This is usually ahieved through a setting in some server configuration file.
    You will have to find out why the server in your application is appending the session id to the url.
    Whatever be the case, the server should be able to look up the session from the incoming request (be it from the session id in the url or a session cookie).
    When session information is exchanged through the JSESSIONID in the url, you should ensure that each and every url that goes to the server has this input parameter. To do that all links and form post urls in your servlet/jsp should be treated with a call to encodeURL().
    For example, in a jsp
       <a href = "<%=response.encodeURL("/nextJsp.jsp")%>">Click here </a>
    or
       <form action = "<%=response.encodeURL("/nextJsp.jsp")%>">
       </form>etc.
    ram.

  • Problem with Javascript in JSP

    Hi Guys,
    I have this problem with my JSP page. I am using a javascript function
    which calls a function within a bean. The problem that I have is that I get an error when trying to call the following function :
    function refDataTypes_onchange()
    Vector empNames = DBQuery.getResult();
    I get a runtime error at the line Vector empNames = DBQuery.getResult;
    Any ideas would be much appreciated.
    Below is the whole code:
    Thanks in advance
    FRank
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    <%@ page import="java.util.*, java.lang.*" %>
    <%-- Declare the java bean for the countries to be queried --%>
    <jsp:useBean id="DBQuery" class="DBQuery" scope="page" />
    <%-- Bean property searchCondition is not set to query countries --%>
    <jsp:setProperty name="DBQuery" property="searchCondition" />
    <%
    Vector empNames = DBQuery.getResult();
    %>
    <HTML>
    <BODY BGCOLOR="GREY">
    <SCRIPT LANGUAGE="JavaScript1.1">
    function refDataTypes_onchange()
    Vector empNames = DBQuery.getResult();
    </SCRIPT>
    <FORM NAME = form1>
    Please enter in the following details
    <p>
    Reference Type :::====
    <select name="refDataTypes" onchange="refDataTypes_onchange()">
    <option value ="1"></option>
    <% for(Enumeration enum = empNames.elements();enum.hasMoreElements();)
    String nextEmpName = (String)enum.nextElement();
    %>
    <option value =<%=nextEmpName%>><%=nextEmpName%></option>
    <%
    %>
    </select>
    <BR>
    <BR>
    Emp No
    <INPUT TYPE="text" NAME=txtAge >
    <BR>
    <BR>
    <INPUT TYPE="button" VALUE="Check Details" NAME=butCheckForm >
    </FORM>
    </BODY>
    </HTML>

    Thanks dimadoo
    I need my JSP to do the following :
    When a user selects a option from a select list. There is a textfield which I want to populate based on the option that thas been selected from the list.
    I tried the following :
    <% Vector empNames = DBQuery.getResult(); %>
    and it does not even go into the bean.
    Will this work if I refresh the page?

  • Problem with forwarding to new page in jsf

    Hi
    I am facing a problem. I have a checkbox in my jsp page and 3 submit button. The two button works w r t check box and its woking fine. I am getting problem with the 3rd button. I want to fwd to next page once the button is clicked.
    For the check box i am using the method
    public String handleCheckbox2ValueChange(ValueChangeEvent valueChangedEvent)
    Can anyone help me in this regard. I need to fwd to the next page.
    Regards
    Rupesh

    This sounds like a simple JSF navigation that has nothing to do with the checkbox. Read the documentation and tutorials on navigation.

  • Problem with String in JSP! Help Me

    Hi all,
    i spent my whole day with this error. How can i solve it. I am trying to convert a string array to Integer array. The program is taking all the select input from the previous JSP page and then converting them into integer array for storing to database. i am catching them as request.getParameterValues(); but i found out that if i select 4 item from the menu it is storing in 8 array cells and the format is if you select 1 2 3 4 the it stores [1 null 2 null 3 null 4 null] i guessed that those are null values. so i have tried to select only 1 2 3 4 from the array and it is showing number format error on tomcat. here is the code guys. Please i am tired of it please help me. Thanks. SORRY I TRIED TO SEPARATE THE CODE BUT IT SEEMS LIKE THERE ARE SOME PROBLEM IN THE FORUM SETTINGS. so the code is:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <%@page import="java.lang.String.*"%>
    <%@page import="java.lang.Character.*"%>
    <%@page import="java.util.*"%>
    <%@page import="java.text.*"%>
    <HTML>
    <HEAD>
    <TITLE> HR ADVANTAGE TIMESHEET </TITLE>
    </HEAD>
    <BODY>
    <%
    String emplno = request.getParameter("emplno");
    String date = request.getParameter("date");
    String proposal = request.getParameter("proposals");
    String network1 = request.getParameter("network");
    String suppassociates = request.getParameter("suppasso");
    String intmngt = request.getParameter("intmgt");
    String client[] = request.getParameterValues("client");
    String client1= request.getParameter("client1");
    String clientunit[] = request.getParameterValues("clientunit");
    String clientunit1=request.getParameter("clientunit1");
    boolean bool=true;
    int staffid = Integer.parseInt(emplno);
    int len=0;
    len=client.length;
    //String[] check_client = new String[len];
    //check_client=client;
    //int check_length=0;
    //check_length=check_client.length;
    //int unitlength=0;
    //unitlength=clientunit.length;
    int arr_length=0;
    arr_length=len-(len/2);
    int[] array = new int[arr_length];
    int j=0;
    j=arr_length;
    for (int i=0; i<len-1; i++)
    bool=true;
    if(client=="\0")
    bool=false;
         if(bool==true)
         array[arr_length-j]=Integer.parseInt(client[i]);
              j=j-1;
              if(j==0)
              break;
    %>
    </BODY>
    </HTML>
    The error is:
    org.apache.jasper.JasperException: For input string: ""
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:367)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.lang.NumberFormatException: For input string: ""
         java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         java.lang.Integer.parseInt(Integer.java:489)
         java.lang.Integer.parseInt(Integer.java:518)
         org.apache.jsp.store_jsp._jspService(store_jsp.java:107)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    what are you trying to test with client [ i ] == "\0"
    You sure you dont need to test against null ?

  • Problem with database using JSP

    Hi
    i am developing one application which uses JSP ..to connect to the database..at present i am using MS-access for the data storage...
    I have two pages in one page there is a form where user fills all the details and once submit the information based on the form has to fetch the data from the backend...i have a problem ..if i hard code the corresponding column name in the JSP page it is getting all the data but if i get it from request.getParameter("")( which i am supposed to be from the form) i am getting no records..
    take a look at the code below and let me know...
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    java.sql.Connection conn= java.sql.DriverManager.getConnection("jdbc:odbc:asiafinity");
    java.sql.Statement stmt=conn.createStatement();
    /* If i print a value from the previous pages its showing but its not going to the database with query statement..
    // String str1=request.getParameter("religion");
    // System.out.println(str1);
    /* If i hardcode the corresponding columun data its querrying the data
    String str1="hindu";
    String sqlquery="select * from userprofile where religion='"+str1+"'";
    System.out.println(str1);
    java.sql.ResultSet cols=stmt.executeQuery(sqlquery);
         while(cols.next()){
    String gen=cols.getString("gender");
    String age=cols.getString("age");
    String rel=cols.getString("religion");
    String cul=cols.getString("culture");
    String loc=cols.getString("location");
    String pro=cols.getString("profession");
    String uname=cols.getString("username"); %>
    <tr><td><a href="<%=uname%>"><%=uname%></td>
    <td><%= gen %></td>
    <td><%= age %> </td>
    <td><%= rel %> </td>
    <td><%= cul %> </td>
    <td><%= loc %></td>
    <td><%= pro %></td>
    </tr>
              <% } %>
    Please help me out..i know this is an simple problem
    Thanks & Regards
    Gnanesh
    </a>

    String str1=request.getParameter("religion");
    String sqlquery="select * from userprofile where religion='"+str1+"'";
    System.out.println(sqlquery);
    try it and tell me what happens

  • JSF with JavaScript ! Problem with OnLoad()

    Hello,
    I have a .js (javascript) file which has one function. I want to call this function in my jsf-jsp page form.
    The javascript run successfully without onload. But when i use onlod it is giving me error like "
    com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: /Webcam.jsp(11,109) Attribute onload invalid for tag body according to TLD
    1. How can i use the onload event with forms or body with jsf ?
    After this, i want to use some if else code with my jsp page. Normally we do this using scriptlets in jsp. So how can i do this on the jsf-jsp. Should i use backing bean to write the same code ?
    Actually i want to invoke different applications based on coditions on the return of my javascrit function.
    Can anybody has tips, solution on this ?
    -Sachin
    EpiComm Technologies Ltd.

    BalusC,
    If we want to set focus to a particular element, then
    this won't work.
    If runScript() function is referring to any form
    element we get an error stating that
    "document..forms.formname.elements is null.
    any ideas how to set focus when the form loads?Then put the script in the bottom of the JSF code, straight before the end body tag. At this place all JSF components are finished with generating.
    <html>
        <head>
        </head>
        <body>
            <f:verbatim>
                <script>
                    setFocus('</f:verbatim><h:outputText value="#{myBean.focusId}" /><f:verbatim>');
                </script>
            </f:verbatim>
        </body>
    </html>

  • Problem with Applets in same page

    Hai to all,
    I am having a problem with GUI in applets
    My first class extends a JPanel named A_a
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
         public void run()
              a=new A_a();
              a.setBackground(new java.awt.Color(255,200,200));
              System.out.println("I AM IN B_b");
              a.text.append(aaa);
              a.text.revalidate();
              getContentPane().remove(a);
              resize(500,500);
         }).start();
    and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
              while(e.hasMoreElements())
                   applets=(Applet)e.nextElement();
                   if ( applets instanceof B_b)
                             System.out.println("I AM CLASS C_c");
                             ((B_b)applets).text_appendText(jta.getText());          
                             ((B_b)applets).remove());
                             ((B_b)applets).getContentPane().add(D_d);
    both the applets C_c and B_b are in same browser page
    How can i achive that pls help .

    please help me its urgent for my project

  • Problem with JavaScript code in Page Attributes, modal popup...

    Hello all!
    I'm encountering a problem with a modal popup I wrote in JavaScript.
    h3.
    The situation*
    A user sees an interactive report with rows that are clickable, so these rows are links. Upon clicking the name of something in a row, some items get a certain value and a modal popup shows on the screen. In this modal popup, there are details regarding that particular row the user has clicked, but the problem_ here is...
    The modal popup closes itself only seconds after it has been opened.
    This must be because I've probably made a mistake somewhere in my code, but I just can't figure out where... It also appears that when I click on a row link, the popup shows, but the progress bar of my toolbar seems to show a loading bar (as if I refreshed the page).
    h3.
    My code*
    This code is located in the _"Function and Global Variable Declaration"_ part, under the _"JavaScript"_ tab. Code is in the _"Page Attributes"_ of my page 24.
    function showhide(x){
    $x('REGION1').style.display = ( x == 'REGION1') ? 'block' : 'none';
    $x('REGION2').style.display = ( x == 'REGION2') ? 'block' : 'none';
    $x('REGION3').style.display = ( x == 'REGION3') ? 'block' : 'none';
    $( function(){
      $('#ModalForm').dialog(
         modal: true,
         autoOpen: false,
         width: 500,
         height: 350,
         buttons:{ Close: function(){closeForm();}        
    function openForm()
        $('#ModalForm').dialog('open');
    function closeForm()
        $('#ModalForm').dialog('close');
        $(document).ready(function() {
            $('a.temppop').click(function() {
                openForm();
        });This code is located in the _"Header Text"_ part, under the _"Header"_ tab. Code is in the _"Page Attributes"_ of my page 24.
    <link rel="stylesheet" href = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"> </script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"> </script>This code is located in the _"Column Link"_ part, you get there by going to the _"Report Attributes"_ of the region called _"Template overview"_ on page 24. This region is an interactive report.
    Link Text: #FOODTEMPLATENAME#
    Link Attributes: class="temppop"
    Target: Page in this Application
    Page: 24
    Item 1, name: P24_MEALID; item 1, value: #MEALTYPEID#
    Item 2, name: P24_TEMPLATEID; item 2, value: #FOODTEMPLATEID#So basically I call the function to open the modal popup by the class name. When a link with that class name in it is clicked, it opens the popup.
    To remind you of the problem, the modal popup closes seconds after it has been opened. How do I fix this?
    Thanks in advance.
    (APEX version 4.1.1.00.23)

    Come on guys... I really need to know this. :(

Maybe you are looking for