JSP , bean, JavaScript

I have a page that uses a bean, myBean. There is a method inside myBean named getOccupation() and a property String Occupation. the getOccupation returns the Occupation to the page. The Occupation String is gotten from a database.
I also have a form in the jsp page named myForm and a select field named Occupation.
The idea is, get the Occupation from the database, return it to the jsp and make the select select the corresponding to the String gotten from the database.
I'm trying to mix javascript with java here
javascript to compare the current values of the Options in select to the Occupation and select it but it keeps giving me the error.
<script>
blabla javascript
<% myBean.getOccupation()%>
</script>
That gives an error, anyone can help?
thx
Dewi

I think the below code might help you.....
I tried to reproduce your problem.....
<%!
     String selectValue = "1";
%>
<html>
     <head>
          <title>Test Page </title>
          <script language="JavaScript">
               function as(){
                    obj = document.form1.test;
                    for (i = 1; i < obj.length; i++){
                         if (obj.value == '<%=selectValue%>')
                              obj[i].selected = true;
          </script>
     </head>
     <body onload="as()">
     <form name="form1">
          <select name="test">
               <option value="">---------select----------</option>
               <option value="1">1</option>
               <option value="2">2</option>
               <option value="3">3</option>
               <option value="4">4</option>
          </select>
     </form>
     </body>
</html>
I hope this works.....

Similar Messages

  • Javascript array / jsp Bean Collection

    How can you fill a javascript array with the values of the collection?
    <jsp:useBean id="programs" scope="request" class="java.util.Collection"/>
      How can I create this array?
    <script language="JavaScript" type="text/javascript">
    var programData =
    new Array ( new Array "${programs[1].programId}","${programs[1].programName}", "${programs[1].department}"),  
                 new Array "${programs[2].programId}","${programs[2].programName}", "${programs[2].department}"),
    </script>

    I answered myself. If anyone else would like to know how to fill a javascript array with the values of a jsp beans collection.
    function collectionToArray()
    Array[rows] = [4];  
    var cnt = 0;
    <c:forEach var="sp" items="${programs}">
      rows[cnt][0] = ${sp.programId};
      rows[cnt][1] = ${sp.programName};
      rows[cnt][2] = ${sp.department};
      rows[cnt][3] = ${sp.urlLink1};
      rows[cnt][4] = ${sp.urlLink2};
      cnt++;
    </c:forEach>  
    }

  • Prob with running jsp Bean

    Hi,
    I am trying to run a bean through a jsp but its giving error at useBean tag of jsp:
    The error is :
    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: /Quadratic.jsp(7,0) The value for the useBean class attribute com.brainysoftware.Quadratic is invalid.
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
         org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
         org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
         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)
    My jsp is:
    <HTML>
    <HEAD>
    <TITLE> JSP BEAN Quadratic Example </TITLE>
    </HEAD>
    <BODY>
    <%@ page language="java" %>
    <jsp:useBean id="quadratic" scope="session" class="com.brainysoftware.Quadratic" />
    <jsp:setProperty name="quadratic" property="ia" param="a" />
    <jsp:setProperty name="quadratic" property="ib" param="b" />
    <jsp:setProperty name="quadratic" property="ic" param="c" />
    X1= <%= quad.getDx1( ) %>
    X2= <%= quad.getDx2( ) %>
    End of program
    </BODY>
    </HTML>my bean is:
    package com.brainysoftware;
    import java.io.*;
    class Quadratic{
    int ia;
    int ib;
    int ic;
    String dx1;
    String dx2;
    public int getIa( ) {
    return ia;
    public void setIa( int ii) {
    ia=ii;
    public int getIb( ) {
    return ib;
    public void setIb(int ii) {
    ib=ii;
    public int getIc( ) {
    return ic;
    public void setIc(int ii) {
    ic=ii;
    public String getDx1( ) {
    double detA;
    double result;
    detA= ib*ib -4*ia*ic;
    if(detA<0.0)
    return "Real Roots not possible";
    else {
    result= -ib - Math.sqrt(detA/(2 * ia));
    Double Dresult=new Double (result);
    return Dresult.toString( );
    public String getDx2( ) {
    double detA;
    double result;
    detA= ib*ib -4*ia*ic;
    if(detA<0.0)
    return "Real Roots not possible";
    else {
    result= -ib + Math.sqrt(detA/(2 * ia));
    Double Dresult=new Double (result);
    return Dresult.toString( );
    my directory structure is given below:
    C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-INF\classes\com\
    brainysoftware>dir
    Volume in drive C has no label.
    Volume Serial Number is 4C50-9542
    Directory of C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-IN
    F\classes\com\brainysoftware
    05/22/2005 11:15 PM <DIR> .
    05/22/2005 11:15 PM <DIR> ..
    05/22/2005 11:18 PM 134 CalculatorBean.java
    05/23/2005 12:12 AM 216 Counter.java
    05/24/2005 10:48 PM 358 SimpleJavaBean.java
    06/14/2005 11:16 PM 1,205 Calculator.java
    06/14/2005 11:16 PM 1,323 Calculator.class
    06/16/2005 06:44 PM 534 CalculatorBean2.java
    06/17/2005 08:53 AM 703 CalculatorBean2.class
    06/16/2005 07:00 PM 352 CalculatorBean2.html
    06/17/2005 08:51 AM 588 CalculatorBean2.jsp
    06/17/2005 04:29 PM 97 UploadBean.java
    06/17/2005 04:43 PM 527 FileUploadBean.java
    06/17/2005 04:43 PM 834 FileUploadBean.class
    06/18/2005 12:21 PM 863 Quadratic.java
    06/18/2005 12:21 PM 1,093 Quadratic.class
    14 File(s) 8,827 bytes
    2 Dir(s) 8,615,821,312 bytes free
    C:\tomcat-5.0.28\jakarta-tomcat-5.0.28\webapps\jsp-examples\WEB-INF\classes\com\
    brainysoftware>
    The above clearly shows the presence of Bean in the reqd directory but still I am getting an error. Can somebody help me:
    Zulfi.

    class QuadraticThe class is not public. It is only visible to other classes in the same package as itself, so the servlet (JSP) trying to instantiate and reference it can't see it.
    Make it public.

  • Set jsp from javascript

    I have three "div" tags in index.jsp ,
    <div id='header'></div>
    <div id='body'></div>
    <div id='footer'></div>
    Now when window is loaded i want other jsp page to be set in the "body" div tag of index.jsp from javascript
    My javascript code
    function invokeJSP(){
    document.getElementById('body').innerHTML="<jsp:include page='test.jsp'>'";
    when I am including this code in <head > part of index.jsp its working the problem is if at all
    In test.jsp
    if i try to include this line
    <% = request.getParameter("name")%>
    its giving an error like "unterminated literal string" in javascript console
    Can anyone help me how to set the jsp from javascript
    Sorry for my bad english.This is the first time I am posting the forum
    thanks
    hema

    hi
    Thanks for the response
    but i have closed the tag in my program. Have u ever tried to invoke jsp from javascript in this way if it works plz help me.
    thanks hema

  • Jsp in javascript

    hi
    can we use jsp in javascript
    for eg:
    <script>
    if(flag)
    <% respone.sendRedirect("--"); %>
    </script>
    or is there any other way of doing this type of things
    this is only an example.
    thx
    -jay

    You can use JavaScript in a JSP. JavaScript usually runs on client. You can also use Java in a JSP. Here is sample code:
    <%@ page import="java.util.*" %>
    <%
    Calendar cal = Calendar.getInstance();
         int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
         int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
         int minuteOfHour = cal.get(Calendar.MINUTE);
         if (((dayOfWeek == 7) & (hourOfDay == 23) & (minuteOfHour > 29)) || ((dayOfWeek == 1) & (hourOfDay == 0) & (minuteOfHour < 31))) { %>  
    <jsp:forward page="file:///M:/Studio/projects/som/html/IC_0019.htm" />
    <% } %>

  • NEWBIE SUPER EASY JSP / BEAN

    With about half a dozen books sitting around my desk, I can't get a REAL basic jsp to work. I FINALLY got tomcat to NOT give run time errors, however the web page simply outputs "This is output:" I know I am an idiot, but this JSP / bean stuff is upsetting. Any help on the following code would be great.
    basic.jsp is as follows:
    <jsp:useBean id="myBean" class="basic.basicbean" scope="session"/>
    <html>
    <head>
    <title>
    A Simple JSP
    </title>
    </head>
    <body>
    <%
    myBean.setBasicName("Michelle");
    %>
    This is output: <% myBean.getBasicName();%>
    </body>
    </html>
    basicbean.java is as follows:
    package basic;
    import java.beans.*;
    public class basicbean {
    private String BasicName=null;
    /** Creates new basicbean */
    public basicbean() {}
    public String getBasicName() {
    return this.BasicName;
    public void setBasicName(String value) {
    this.BasicName = value;
    Made the .java into the class put it in the basic directory under the classes/basic directory of the WEB-INF. The JSP page loads, but only output is: "This is output:" I am using Tomcat as the JSP server. "Core JSP" "Core Servlets and JavaServer Pages" "Advanced JavaServer Pages" "JSP, Servlets, and MySQL", and "Java Server Pages for Dummies" and I still can't get it. Thanks for helping out an idiot.
    -Jim

    You are very close; just a small error in the line:
    This is output: <% myBean.getBasicName();%>
    The problem is your just simply calling the method and tossing the return value. You have three ways of outputing the bean property:
    This is output: <% out.print(myBean.getBasicName();%>
    or
    This is output: <%=myBean.getBasicName()%>
    or
    This is output: <jsp:getProperty name="myBean" property="BasicName" />
    If you use the <jsp:getProperty> approach, then you must have a <jsp:useBean> somewhere above the getProperty tag.
    - Chris

  • JSP language javascript

    What is the problem?
    <%@ page language="javascript" %>
    <%
    var i;
    for ( i=1; i<5; i++ )
    out.println("JSP whit JavaScript <br>");
    %>

    What is the problem?
    <%@ page language="javascript" %>
    <%
    var i;
    for ( i=1; i<5; i++ )
    out.println("JSP whit JavaScript <br>");
    %>The <% and %> tags indicate a Java scriptlet.
    "var" is JavaScript syntax, the rest is Java.
    out.println is a Java method.
    If you want to do your loop in JavaScript then it would
    be like this:
    <script>
    for ( var i = 1; i < 5; i++ )
    document.writeln("JSP whit JavaScript <br>");
    </script>

  • Redundant information in JSP bean action

    Class Person:
    public class Person{
    private String name;
    public void setName(String p){
    name=p;
    public String getName(){
    return name;
    }Code in servlet:
    public void doPost(HTTPServletRequest request, HTTPServletResponse response) throws IOException,ServletException{
    foo.Person p= new foo.Person();
    p.setName("New Guy");
    request.setAttribute("person",p);
    RequestDispatcher view = request.getRequestDispatcher("result.jsp");
    view.forward(request,response);
    }Code in JSP:
    <jsp:useBean id="person" class="foo.Person" scope="request">This jsp:useBean tag really is confusing. Why does it need to declare the class="foo.Person"? Why does the JSP need to know that "person" instance is derived from class foo.Person ? (I wonder if I changed this to foo.person --> not Person will result in error). Doesn't the statement request.setAttribute("person",p) from the servlet give enough info already to the JSP? thanks

    The "person" in your servlet has nothing to do with your "person" in your JSP bean tag.

  • Create jsp/bean webapp deploy fine...  add JSTL library wont deploy!

    winxp
    SJSE8
    PROBLEM:
    Using the new project wizard, I create a simple jsp/bean webapp using the embedded tomcat 5.5.7 as server... It deploys and runs with now issue
    Then, I right-click on project name (in project tree)... click properties... add library... select "JSTL 1.1".... do clean/build.... do deploy - which fails!
    message is: "Failed to deploy application at context path /bcd" (where bcd is my project name)
    Why does this happen?
    --------------simple app---------------
    ***jsp1.jsp****
    <%@page contentType="text/html"%>
    <%@page 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>
        <h1>JSP Page</h1>
        <h1>get stuff JSP Page</h1>
        <jsp:useBean id="a" class="bcdpkg.IndexBean" scope="request"/>
        <h3>after1...</h3>
        <!--jsp:setProperty name="a" property="stuff" value="xxx" /-->
        <jsp:getProperty name="a" property="stuff" />
        </body>
    </html>***IndexBean.java***
    package bcdpkg;
    public class IndexBean
        /** Creates a new instance of IndexBean */
        public IndexBean()
        private String stuff = "this is stuff";
        public String getStuff()
            return this.stuff;
        public void setStuff(String s)
            this.stuff = s;
    }

    well.... I restarted SJSE8 (and tomcat 5.5.7) and now I can right-click on the project and click deploy...successfully.
    (Apologies for the "hair trigger" posting)
    I'll reply once more if it happens again.
    thanx

  • Redirect from jsp bean to jsp or html page

    I am facing a problem in redirecting to a jsp page from jsp bean
    How do i redirect from jsp bean to any other page like jsp or html.
    [email protected]

    Hi
    The solution you suggested we tried it long before only but it is not feasible for us as we have to implement it in all web pages which are in thousands.
    My need is like this.
    We have given specific time to each of our registered user , as user logs to our portal we calculate session time in bean and as he logs out is new time gets updated. (its like dial up connection)
    Now what happens consider user has left only 10 minutes balance, I can calculate and keep track for his time in bean.Now as the time becomes zero I want to redirect him to home page.
    As u said i can get return value zero for bean and can do it ,but our webpages are near about thousands.

  • Calling JSP bean function on button OnClick

    Hi-
    A NewBie question....
    I have a .jsp page and supporting .java bean.
    I registed the bean in .jsp page using <jsp:useBean ...>
    I want to fire a function defined in that bean on the click of a button which is defined in the .jsp page
    So I am doing something like this... seems like not the correct way to do since it fires this script all the time, not just when the button is clicked.
    <input name='click1' type='Submit' value='Click1' onClick='<% testBean.click1Clicked (); %>'/>
    Thanks for your help.

    Hi Kishor-
    Thanks for the reply.
    I realize that might be the case, as u explained in your two points.
    so now I have created a hidden input field and use it's value as a way to communicate between javascript and jsp. and in bean's function I check the value of this hidden field, which will be set by the OnClick's javascript and then proceed accordingly.
    Is this the correct way to accomplish what I am trying to?
    Thanks again

  • WL vs. WL-express and JSP vs. javascript/SQL

    folks-
    i am trying to convince a certain party to
    disband a web-based job tracking system being
    written in ASP, javascript, html, css and SQL.
    it will be hosted on MS webserver running NT.
    i am trying to convince them to use JSP and
    WL express. i have done two years of EJB
    component work on weblogic, however, i have not
    done work with JSP or thin-clients. i was mostly
    business-logic.
    anyway i have some questions and need some
    direction. i already know JSP is better than
    ASP/javascript etc. because:
    * ASP is proprietary. ditto for VBscript
    * with an IDE creating JSP is easy and JSP
    automatically creates servlets which is way
    faster than by hand
    * JSP is JAVA based and hence benefits from
    all the portability pluses of JAVA
    but here are the more difficult questions:
    * why is WL express better than an MS
    web server? (not including WL market share
    and size. after all MS can claim that)
    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?

    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    Use JDO or an OR-mapper or embed JDBC into your own data access classes.
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    Presentation=JSP
    Logic=Servlet
    Data access=JDO or similar
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    You should be able to tell up front if it a tx-intensive app that requires
    WLS.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    They aren't exclusive. For dynamic pages, use Javascript on the front end,
    JSP on the back.
    * with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?
    In the real world, and for most apps, while Java has the architectural edge,
    they both have similar scalability and similar robustness. MS gives you no
    choice though, and you rewrite every time they see a new buzzword. You can't
    leave MS-land without abandoning almost everything. You can leave WLS in a
    week if you have to.
    It's an investment. Invest wisely.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "shane miller" <[email protected]> wrote in message
    news:[email protected]...
    folks-
    i am trying to convince a certain party to
    disband a web-based job tracking system being
    written in ASP, javascript, html, css and SQL.
    it will be hosted on MS webserver running NT.
    i am trying to convince them to use JSP and
    WL express. i have done two years of EJB
    component work on weblogic, however, i have not
    done work with JSP or thin-clients. i was mostly
    business-logic.
    anyway i have some questions and need some
    direction. i already know JSP is better than
    ASP/javascript etc. because:
    * ASP is proprietary. ditto for VBscript
    * with an IDE creating JSP is easy and JSP
    automatically creates servlets which is way
    faster than by hand
    * JSP is JAVA based and hence benefits from
    all the portability pluses of JAVA
    but here are the more difficult questions:
    * why is WL express better than an MS
    web server? (not including WL market share
    and size. after all MS can claim that)
    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?

  • Jsp-bean usage

    here's the jsp
    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    <jsp:useBean id="mybean" class="beans.MyBean" scope="page"></jsp:useBean>
    <!-- means u can call the methods in the bean using the object   -->
    <jsp:setProperty property="*" name="mybean" />
    <!-- all setters in the bean will be run on page submit-->
    <jsp:useBean id="Static" class="webinsert.beans.StaticBean"></jsp:useBean>
    <html>
         <head>
              <title>  </title>
              <link rel='stylesheet'
                   href='  '
                   type="text/css">
              <script type="text/javascript">
    function submitMe()
    document.forms[0].submitt.value='true';
    document.forms[0].submit();
              </script>
         </head>
    <%
    String x=request.getParameter("submitt");
    if(x!=null && x.equalsIgnoreCase("true"))//the form was submitted
              out.println("Note how Value in the field persisted <br>");
              mybean.print();
    %>
         <body >
              <form method=post >
    Enter a value in the text field , press the button , and see ur console
              <input type="hidden" name="submitt" value="" />
              <input type=text name=myTextField size=20 value="<%=mybean.getMyTextField() %>"/>
              <input type=button value=submit onclick="submitMe();"/>
              </form>
         </body>
    </html>here's the bean
    package beans;
    public class MyBean
              String myTextField = "";
              public String getMyTextField ()
                        return myTextField ;
              public void setMyTextField (String myTextField )
                        this.myTextField = myTextField ;
    public void print()
              System.out.println("Value of myTextField  "+myTextField );
    }

    And where is your question?

  • Jsp inside javascript

    hello ppl,
    i want to know if its possible to execute JSP code inside javascript..

    hi damion,
    thanks for being so nice.. and wat i want to do is pretty simple.. i have a jsp page with a text field and a button in it. wat i want is, everytime the button is clicked, data from a field in the database should be displayed sequentially, i.e something similar to generating the next sequential rollno when we click 'next'. Also the sql query to be submitted is also generated dynamically in the JSP page. how can i go about doing database operations using javascript? or is there any other simpler way of doin it? hav i made myself clear?
    ll send u the code which i've employed..
    this is the jsp page:
    <HTML>
         <HEAD>
              <TITLE>
                   Welcome to fstaff1.jsp
              </TITLE>
    <jsp:useBean scope = "page" id = "rollnogenerator1" class = "coreservlets.rollnogenerator" />
    <script>
    function generate(){
    fstaff1.regno.value = <%=rollnogenerator1.getRollNo()%>;
    }</script>
         </HEAD>
         <BODY>
    <%
    rollnogenerator1.setQuery("select * from marks");
    rollnogenerator1.connect();
    %>
    <form name = 'fstaff1' method = 'post'>
    <input type='text' name = 'regno' value = <%=rollnogenerator1.getRollNo()%>>
    <input type='button' name = 'next' value='next' onclick='genrerate()'>
    </form>
         </BODY>
    </HTML>
    and here is the bean i used:
    package coreservlets;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class rollnogenerator {
    public rollnogenerator() {
    private String query = "not set yet";
    ResultSet rs;
    private String rollno;
    public void connect(){
    try{
    Class.forName("org.postgresql.Driver");
    Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost/pulls","postgres","this");
    Statement st = connection.createStatement();
    rs = st.executeQuery(query);
    rs.next();
    catch(Exception e){}
    public String getRollNo(){
    try{
    rollno = rs.getString(4);
    rs.next();
    catch(Exception e){}
    return(rollno);
         public void setQuery(String msg){
    this.query = msg;
    public static void main(String[] args) {
    can u help?

  • How to access variables across JSP and JavaScript?

    Hi,
    I have some .js files and in those files, some of the methods need to access to the variables that I'd declare in the jsp files. How do I do it?
    Anne

    You can do it this way, but I'm not sure if this is what you had in mind.
    Say you had a java variable called XString. And you wanted to display
    the value of XString in a javascript Alert. Here's how:
    <html>
    <body>
    <% String XString = "Hi There!"; %>
    </body>
    <script language="javascript">
    alert("<%=XString%>");
    </html>Hope This Help,
    P.

Maybe you are looking for

  • HDMI vs Mini DP vs DVI vs Thunderbolt

    I have a mid-2009 MacBook Pro with 8GB of RAM and a 2.26 GHz processor. When I connect to an external monitor and try to watch videos on youtube or netflix, I get choppy quality. This does not happen on my laptops display even while the external moni

  • How do I print my pictures from Photoshop Elements 8?

    Hi, I purchased and Adobe Photoshop Elements 8 from a garage sale and have downloaded the software onto my computer. I have posted pictures and edited them, but I am unable to pass the pictures to any site to be printed. I have registered the photosh

  • Which is better to buy?

    Hi !! I don know whether this is valid question to ask in this section. I am trying to buy new android smart phone but confused with lot of models so pls suggest me which one is good to buy I marked few models like htc desire u,v,w , galaxy grand qua

  • Tutorial won't start

    tutorial won't start at all fust goes from play to pause with out running

  • Has to do with a USB Flash Stick

    I bought a Kingston DataTraveler 100 (1GB) and I want to put photos on the stick to use in a Digital Photo Frame I was given for Christmas. I was able to put 112 photos on the stick but then it told me it was full when there was still almost 800mb le