Multilingual JSP page

I am trying to build a multilingual web page using ResourceBundle class.
What I want is to have the table title to be multilingual. I have defined
two properties files "title_en_US.properties" and "title_zh_CN.properties".
I have earlier used the native2ascii tool to convert the chinese characters
to string as shown below for the chinese properties file
name=\u00e5\u00b8\ufffd\u00e5\ufffd\u00b7
In my "Load.jsp", I notice that in IE 5.5 it will display
the chinese title as garbage character as the page content type
is defaulted to Western ISO language encoding.
If I manually change encoding to Unicode using via the IE menu with
steps "View/Encoding/Unicode", the garbage characters becomes Chinese.
I tried to have another JSP "LoadUTF8.jsp" which specifies the page encoding
as UTF-8. The IE browser shows the page encoding defaults to Unicode but
the chinese title is still displayed as garbage characters.
Where did I go wrong? Any help on this is much appreciated.
Thank you.
Regards,
Chee Keong
Here is a brief code of the "Load.jsp" JSP
<%@ page language="java" contentType="text/html" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.ResourceBundle" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<!-- Load.jsp -->
<%
Locale mylocale = null;
String language = request.getParameter("lang");
if ("zh".equalsIgnoreCase(language))
mylocale = new Locale("zh","CN");
else
mylocale = new Locale("en","US");
ResourceBundle bundle = ResourceBundle.getBundle("title", mylocale);
%>
<head>
<title>Testing</title>
</head>
<body>
<h3> Welcome </h3>
<table border="1">
<tr><td><%= bundle.getString("name") %></td></tr>
</table>
</body>
</html>
Here is a brief code of the "LoadUTF8.jsp" JSP
<%@ page contentType='text/html; charset=UTF-8' %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.ResourceBundle" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<!-- LoadUTF8.jsp -->
<%
Locale mylocale = null;
String language = request.getParameter("lang");
if ("zh".equalsIgnoreCase(language))
mylocale = new Locale("zh","CN");
else
mylocale = new Locale("en","US");
ResourceBundle bundle = ResourceBundle.getBundle("title", mylocale);
%>
<head>
<title>Testing</title>
</head>
<body>
<h3> Welcome </h3>
<table border="1">
<tr><td><%= bundle.getString("name") %></td></tr>
</table>
</body>
</html>

I'm not sure what is wrong with your code, but here's a test JSP page I was using to test Chinese input and display:
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <meta name="Generator" content="TextPad 4.0" />
     <meta name="Author" content="" />
     <meta name="Keywords" content="" />
     <meta name="Description" content="" />
</head>
<body bgcolor="#ffffff" background="" text="#000000" link="#ff0000" vlink="#800000" alink="#ff00ff">
<%
request.setCharacterEncoding("UTF-8");
String str = "\u7528\u6237\u540d";
String name = request.getParameter("name");
if(name != null) {
     // instead of setCharacterEncoding...
     //name = new String(name.getBytes("ISO8859_1"), "UTF8");
System.out.println(application.getRealPath("/"));
System.out.println(application.getRealPath("/src"));
%>
req enc: <%= request.getCharacterEncoding() %><br />
rsp enc: <%= response.getCharacterEncoding() %><br />
str: <%= str %><br />
name: <%= name %><br />
<form method="GET" action="_lang.jsp" encoding="UTF-8">
Name: <input type="text" name="name" value="" >
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

Similar Messages

  • How to use single JSP page for multiple users.

    Hi ,
    I am doing messenger kind of program using JSP and tomcat server.
    When i type message it is showing in the some div. If some other person request for the same page by giving my IP address and jsp page, he should able to see what i have typed on page so far.
    how can i do that one . can any one guide me .
    Thanks in advance.

    SuneelGoodatJava wrote:
    Hi ,
    I am doing messenger kind of program using JSP and tomcat server.
    When i type message it is showing in the some div. If some other person request for the same page by giving my IP address and jsp page, he should able to see what i have typed on page so far.
    how can i do that one . can any one guide me .
    Thanks in advance.HTTP is a request/response protocol. You can't do what you're suggesting without "pushing" what you type to all the other users. That's not the way HTTP works. Maybe an applet and servlet.
    %

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • Error While opening a JSP page from inside form window

    Hi,
    I am using Oracle EBS 12.0.4 and using IE 7 as my browser.
    Now when i am trying to open a jsp page form EBS Home page (after login) it is opening perfectly.The problem occurs when i tried to open jsp pages from inside form window.
    E.g. From the home page when i tried to open a jsp page "Control Purchasing Periods" which is assigned in one of our custom responsibility(Manager Systems-->PO Super User-->Set up-->Financials-->Accounting-->Control Purchasing Periods) it opens a new log in page for the EBS. When i logged in it is showing
    Error
    You have insufficient privileges for the current operation. Please contact your System Administrator. Same is happening when i am trying to open User Page form user management responsibility from inside a form window.Where as it is opening fine from home page.
    Please help.

    Hi, hueesin
    in error log i got this 4 new lines while performing the transaction from my host
    [Thu Dec 30 13:27:39 2010] [error] [client 172.16.6.144] [ecid: 1293695859:172.16.48.61:25634:0:8748,0] Directory index forbidden by rule: /dev02/KMCTEST/apps/apps_st/comn/java/classes/
    [Thu Dec 30 13:27:40 2010] [error] [client 172.16.6.144] [ecid: 1293695860:172.16.48.61:25328:0:8829,0] Directory index forbidden by rule: /dev02/KMCTEST/apps/apps_st/comn/java/classes/
    [Thu Dec 30 13:28:06 2010] [error] [client 172.16.6.144] [ecid: 1293695886:172.16.48.61:25654:0:9225,0] File does not exist: /dev02/KMCTEST/apps/apps_st/comn/java/classes/oracle/forms/engine/RunformBundle_en_IN.class
    [Thu Dec 30 13:28:06 2010] [error] [client 172.16.6.144] [ecid: 1293695886:172.16.48.61:25654:0:9226,0] File does not exist: /dev02/KMCTEST/apps/apps_st/comn/java/classes/oracle/forms/engine/RunformBundle_en_IN.propertieswhile in access log i got
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "POST /OA_HTML/OA.jsp?page=/oracle/apps/fnd/sso/login/webui/MainLoginPG&_ri=0&_ti=587084970&language_code=US&requestUrl=http%3A%2F%2Fkmctapp2.kmc.com%3A8005%2FOA_HTML%2FRF.jsp%3Ffunction_id%3D2014%26resp_id%3D50670%26resp_appl_id%3D7000%26security_group_id%3D0%26lang_code%3DUS%26params%3Df7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0%26oas%3DAuZa28Bnhl7glqYyqXbjsg..&cancelUrl=http%3A%2F%2Fkmctapp2.kmc.com%3A8005%2FOA_HTML%2FAppsLogin&langCode=US&oapc=2&oas=rucHEnmoEQ25-3xRNnl0ZA.. HTTP/1.1" 302 708 1 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=28636&resp_id=-1&resp_appl_id=-1&security_group_id=0&lang_code=US&params=Br702.NFW.nrlg1EodytbsK-Dc1k9ERgGeColziC.cPOIi7hiyjaPiR6AJ7.Lk4IUbiFt8MZ-sww1yPk9nLXIYqdPHfttMeywkt5IQhVsrG8Y9M-0CrrcAU8ZntmtaFjlkc2vXbUaot6TQpdqAPHJyaJn6YLsew516hhfiB2xemOmo6e-.WpPrlXfvBQG.XVr-Z8y-V4uRkwwHgWHTK.ju6jLsF35BmqTRszq39cgoHe38QZqjtonDRWgTFzvxooOAmX1EHPfxfMz88uKnVWnnzU-4996ZD8e3X0Dagp19gjOYgefJlT1fTUaFvMo3cP.-7Ypt0s4Cck.GhdFOnHRK1Ok6KdvnjFyjK-WHCy4ZHCvw3NZPREYBngqJc4gvnDziIu4Yso2j4kegCe-i5OCFG4hbfDGf7MMNcj5PZy1yFwJ8GIMHyNmCAg9Yo1bXn5cTHOy7xYWHyOD5.ax3JG6Q&oas=W0vxAqkroMB_7DgeNPZhYw.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "GET /OA_HTML/RF.jsp?function_id=2014&resp_id=50670&resp_appl_id=7000&security_group_id=0&lang_code=US&params=f7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0&oas=AuZa28Bnhl7glqYyqXbjsg.. HTTP/1.1" 200 7534 0 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=28636&resp_id=-1&resp_appl_id=-1&security_group_id=0&lang_code=US&params=Br702.NFW.nrlg1EodytbsK-Dc1k9ERgGeColziC.cPOIi7hiyjaPiR6AJ7.Lk4IUbiFt8MZ-sww1yPk9nLXIYqdPHfttMeywkt5IQhVsrG8Y9M-0CrrcAU8ZntmtaFjlkc2vXbUaot6TQpdqAPHJyaJn6YLsew516hhfiB2xemOmo6e-.WpPrlXfvBQG.XVr-Z8y-V4uRkwwHgWHTK.ju6jLsF35BmqTRszq39cgoHe38QZqjtonDRWgTFzvxooOAmX1EHPfxfMz88uKnVWnnzU-4996ZD8e3X0Dagp19gjOYgefJlT1fTUaFvMo3cP.-7Ypt0s4Cck.GhdFOnHRK1Ok6KdvnjFyjK-WHCy4ZHCvw3NZPREYBngqJc4gvnDziIu4Yso2j4kegCe-i5OCFG4hbfDGf7MMNcj5PZy1yFwJ8GIMHyNmCAg9Yo1bXn5cTHOy7xYWHyOD5.ax3JG6Q&oas=W0vxAqkroMB_7DgeNPZhYw.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "GET /OA_HTML/cabo/images/swan/t.gif HTTP/1.1" 304 0 0 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=2014&resp_id=50670&resp_appl_id=7000&security_group_id=0&lang_code=US&params=f7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0&oas=AuZa28Bnhl7glqYyqXbjsg.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "GET /OA_HTML/cabo/images/swan/errorl.gif HTTP/1.1" 304 0 0 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=2014&resp_id=50670&resp_appl_id=7000&security_group_id=0&lang_code=US&params=f7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0&oas=AuZa28Bnhl7glqYyqXbjsg.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "GET /OA_HTML/cabo/images/swan/navBarUnderTopTabsBg.gif HTTP/1.1" 304 0 0 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=2014&resp_id=50670&resp_appl_id=7000&security_group_id=0&lang_code=US&params=f7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0&oas=AuZa28Bnhl7glqYyqXbjsg.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
    172.16.6.144 - - [30/Dec/2010:13:32:51 +0530] "GET /OA_HTML/cabo/images/swan/footerBg.gif HTTP/1.1" 304 0 0 "http://kmctapp2.kmc.com:8005/OA_HTML/RF.jsp?function_id=2014&resp_id=50670&resp_appl_id=7000&security_group_id=0&lang_code=US&params=f7B5hnH8rkFfR.idy0MT1JZrquJxVBy3CVpSV.GpXc0&oas=AuZa28Bnhl7glqYyqXbjsg.." "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"

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

  • Issue in applying SSL selectively to Login JSP Page--Session getting lost.

    Hi,
    I am facing some issues with SSL configuration on my web site running on tomcat 5.5. I am using jdk 1.5 and form based authentication with JAAS framework.
    The SSL configuration is working perfectly when applied to complete web site, but starts giving problem when applied selectively to some JSP pages. At present I am trying to apply SSL just on the login page.
    When the login screen loads up, the URL in the browser has a protocol "*https*", as expected, but it doesn't gets changed to "*http*" once the user has successfully logged in. Why is the automatic change from https to http not ocurring?
    Also I want to know which is the default page, tomcat will direct the logged in user to, once successfully authenticated using form based login; Is there any way to change this default page to some other page. It looks like that tomcat automatically directs to index.html , once the user has been successfully authenticated, but I am not so sure. My index.html page is having 4 frames; the source of these frames are different JSP pages, which are not under SSL.
    My aim is to apply SSL just on login.jsp so that password doesn't travel in clear text. Once the user is authenticated he should see index.html and the address bar's URL should change it's protocol from https to http.
    Please, find below the code in my web.xml
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>CWA Application</web-resource-name>
    <url-pattern>/about.jsp</url-pattern>
    <url-pattern>/admin_listds.jsp</url-pattern>
    <http-method>DELETE</http-method>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    <http-method>PUT</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <security-constraint>
    <web-resource-collection>
    <url-pattern>/*login.jsp*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>CWA Application</realm-name>
    <form-login-config>
    <form-login-page>/login.jsp</form-login-page>
    <form-error-page>/login.jsp?error=true</form-error-page>
    </form-login-config>
    </login-config>
    <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
    My login. jsp has below code:
    <form name="login" method="POST" action='<%= response.encodeURL(*"j_security_check*") %>' >
    <tr>
    <td width="100%">
    <table width="260" border="0" cellspacing="0" cellpadding="1">
    <tr>
    <td align="left" valign="top" rowspan="4"><img src="images/space.gif" width="15" height="5"></td>
    <td align="right" class="login-user" nowrap ><p>User name: </p></td>
    <td align="left" valign="top"><input maxLength="64" name="j_username" size="20"></td>
    </tr>
    <tr>
    <td align="right" nowrap class="login-user"><p>Password: </p>
    </td>
    <td align="left" valign="top">
    <input maxLength=\"64\" tabindex="2" type="password" name="j_password" size="20">
    </td>
    </tr>
    </form>
    The entries in my server.xml are following:
    <Connector port="8080" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
    maxThreads="150" scheme="https" secure="true"
    keystoreFile="${java.home}\lib\security\cacerts" keystorePass="changeit"
    clientAuth="false" sslProtocol="TLS" />
    I have gone through the http://forums.sun.com/thread.jspa?threadID=197150 and tried implementing it; The filter as explained in the thread does gets called but the session values are still lost.
    Please note I am using javascript to go from secure "https" to "http" once the user has successfully logged in The javascript code is as below:
    top.location.href="http://localhost:8080/qtv/index.html." ;
    If I use response.sendRedirect("http://localhost:8080/qtv/index.html") for going to non-secure mode, the index.html page does not gets loaded properly. (Please note that my index.html is made of *4 frames*, as explained earlier. This is a legacy code and frames can't be removed).
    The reason for index.html not getting loaded properly is that the Address bar URL does NOT change its URL and protocol from https (https://localhost:8443/qtv/index.html ) to "*http*" (http://localhost:8080/qtv/index.html) when esponse.sendRedirect() is used ;this is the default behaviour of response.sendRedirect(). And because the protocol in address bar is https, index.html is not able to load the other JSP's in it's frames because of cross-frame-scripting security issues (The other JSP's to be loaded in frames are are NOT secure as discussed earlier).
    Please let know if any way out.
    Thanks,
    Masaai

    Hi
    try to set the maximum interval between requests
    eg:
    session.setMaxInactiveInterval(6000);
    vis

  • Pls help me writing logic:iterate tag in jsp page

    Hey guys , I am struck in retriving string p1,p2,p3 in the jsp page
    Pls have a look ata the code
    In DAO class:-
    StdprdDAO.java
    Public arrayList getPFP()
    ArrayList a = new ArrayList();
    While(rs.next())
         columnsVO colVO = new columnsVO;
         colVO.setProduct(rset.getString(1));//will store in String colProduct
         colVO.setFamily(rset.getString(2));//will store in String colFamily
    colVO.setPrice(rset.getString(3));//will store in String colPrice
    a.add(colVO);
    return a;
    In Action Class:-
    ArrayList final = null;
    StdprdDAO DAO = new stdprdDAO();
    final = DAO.getPFP();
    For(int i = 0; final !=null && i<final.size() ; i++)
         columnsVO VO = null;
         VO = (columnsVO)final.get(i);
         String p1 = (String) VO.getProduct();
         String p2 = (String) VO.getFamily();
         String p3 = (String) VO.getPrice();
         Request.setAttribute(“p1”,p1);
         Request.setAttribute(“p2”,p2);
         Request.setAttribute(“p3”,p3);
    In JSP PAGE:-
    id = “columnsVO”>
    <bean:write name = “columnsVO” property=”final” id=”p1”>
    but still I am doubting my above sentences in jsp page ,so pls correct them if possible.
    Instead of l;ogic:iterate can I use directly getattribute(“p1”)? <logic:iterate
    Still I m doubting I can not utilize columnsVO file in logic:iterate, I can utilize only formbean file.
    So pls help me with this.

    May I ask why have you done it?
    If it is related to printing of the list then it is of no use.But it IS of use. The objects compEmployees is in scope.
    It has the list we want to print out.
    With logic:iterate:
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <logic:iterate name="compEmployees" property="totalEmps" id="emp">
              <tr>
                <td>
                  <bean:write name="emp" property="empNo"/>
                </td>
                <td>
                  <bean:write name="emp" property="empName"/>
                </td>
              </tr>
         </logic:iterate>
    </table>or alternatively with JSTL and c:forEach
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <c:forEach items="${compEmployees.totalEmps}" var="emp">
              <tr>
                <td>
                  <c:out value="${emp.empNo}"/>
                </td>
                <td>
                  <c:out value="${emp.empName}"/>
                </td>
              </tr>
         </c:forEach>
    </table>Cheers,
    evnafets

  • [b]Error during JSP page processing[/b]

    hi , i'm mech.
    i have some probs with jsp. i am trying to connect jsp page with database and printing the data on the browser page. i have created DSN mm using microsoft odbc for oracle and oracle9i's driver oracle in orahome90 but it is giving yet . i have this coding and error.
    ------------------------jsp code--------------------------
    package pagecompile.jsp;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.FileInputStream;
    import java.io.ObjectInputStream;
    import java.util.Vector;
    import com.sun.server.http.pagecompile.jsp.runtime.*;
    import java.beans.*;
    import com.sun.server.http.pagecompile.jsp.JspException;
    import java.sql.*;
    public class _Connect extends HttpJspBase {
    static char[][] jspxhtml_data = null;
    public _Connect( ) {
    private static boolean jspxinited = false;
    public final void jspxinit() throws JspException {
    ObjectInputStream oin = null;
    int numStrings = 0;
    try {
    FileInputStream fin = new FileInputStream("E:\\JavaWebServer2.0\\tmpdir\\default\\pagecompile\\jsp\\pagecompile.jspConnect.dat");
    oin = new ObjectInputStream(fin);
    jspxhtml_data = (char[][]) oin.readObject();
    } catch (Exception ex) {
    throw new JspException("Unable to open data file");
    } finally {
    if (oin != null)
    try { oin.close(); } catch (IOException ignore) { }
    public void _jspService(HttpServletRequest request, HttpServletResponse  response)
    throws IOException, ServletException {
    boolean jspxcleared_due_to_forward = false;
    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    String _value = null;
    try {
    if (_jspx_inited == false) {
    jspxinit();
    jspxinited = true;
    _jspxFactory = JspFactory.getDefaultFactory();
    response.setContentType("text/html");
    pageContext = _jspxFactory.getPageContext(this, request, response,
                   "", true, 8192, true);
    application = pageContext.getServletContext();
    config = pageContext.getServletConfig();
    session = pageContext.getSession();
    out = pageContext.getOut();
    out.print(_jspx_html_data[0]);
    out.print(_jspx_html_data[1]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(14,2);to=(28,2)]
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection myconn=DriverManager.getConnection("Jdbc:Odbc:mm","madhulika","madhulika");
    Statement stmt = myconn.createStatement();
    ResultSet myResultSet = stmt.executeQuery("Select * from peopletable");
    if(myResultSet != null)
         while(myResultSet.next())
              int eid=myResultSet.getInt("id");
              String fname=myResultSet.getString("firstname");
              String lname=myResultSet.getString("lastname");
              String mail=myResultSet.getString("email");
    // end
    out.print(_jspx_html_data[2]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(30,10);to=(30,13)]
    out.print(eid);
    // end
    out.print(_jspx_html_data[3]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(31,10);to=(31,15)]
    out.print(fname);
    // end
    out.print(_jspx_html_data[4]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(32,10);to=(32,15)]
    out.print(lname);
    // end
    out.print(_jspx_html_data[5]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(33,10);to=(33,14)]
    out.print(mail);
    // end
    out.print(_jspx_html_data[6]);
    // begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(37,5);to=(43,0)]
    stmt.close();
    myconn.close();
    // end
    out.print(_jspx_html_data[7]);
    } catch (Throwable t) {
    if (out.getBufferSize() != 0)
    out.clear();
    throw new JspException("Unknown exception: ", t);
    } finally {
    if (!_jspx_cleared_due_to_forward)
    out.flush();
    _jspxFactory.releasePageContext(pageContext);
    -------------------error in browser----------------------
    Error during JSP page processing
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
         at java.lang.Throwable.(Compiled Code)
         at java.lang.Exception.(Compiled Code)
         at java.sql.SQLException.(SQLException.java:43)
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3814)
         at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1029)
         at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:145)
         at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:165)
         at java.sql.DriverManager.getConnection(Compiled Code)
         at java.sql.DriverManager.getConnection(DriverManager.java:126)
         at pagecompile.jsp._Connect._jspService(Compiled Code)
         at com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet.java:469)
         at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspServlet.java:259)
         at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.java:97)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at com.sun.server.ServletState.callService(ServletState.java:226)
         at com.sun.server.ServletManager.callServletService(ServletManager.java:936)
         at com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
         at com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
         at com.sun.server.http.stages.Runner.process(Runner.java:79)
         at com.sun.server.ProcessingSupport.process(Compiled Code)
         at com.sun.server.Service.process(Service.java:204)
         at com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java:374)
         at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
         at com.sun.server.HandlerThread.run(Compiled

    Backing up a moment, is there a particular reason that you're using the JDBC-ODBC bridge rather than using the Oracle JDBC driver?
    Have you taken a look at the JSP sample code available on OTN? I would start by making sure you can run that.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Loading a .jsp page from another .jsp page?

    Hi,
    I have following IF statement in "Main.jsp" page to load "ChangeJob.jsp" page. I tested and made sure that The IF condition was true(alert function executed), but ChangeJob.jsp didn't load.
    Did i miss something?
    Main.jsp
    <HTML>
    <% if ( (!(woSt.equals("Indirect"))) && (woSt.length()!=0) ){%>
    <SCRIPT>
    alert("click OK to load Changejob.jsp");
    document.form1.action="ChangeJob.jsp";
    document.form1.submit();
    </SCRIPT>
    <%} %>
    <BODY>
    <form name="form1">
    </form>
    </BODY>
    </HTML>

    Hi,
    The folloing code I am writing but in this my if loop is not working propery.
    the problem I am checking for this...
    if((!(progcode.equals(pall))) && (!(dcode.equals(dall))) && (!(yr.equals(yall))))
    in the belo program I am using but always it is going in to the loop. when they are equal and when they r not eqal....
    I have given compleate code in here pleace tell me hot to get it worked it properly.....
    <%@ page language="java" session="true"%>
    <%@ include file="connect.jsp"%>
    <%! ResultSet rs2,rs1;
    Statement stmt1,stmt2;
    %>
    <%
    String gpcode=null,pname=null,dname=null,total=null,totalyr=null,gtotal=null;
    int gdcode=0,gyear=0,gdata=0,deptcode=0;
    String pall=null,dall=null,yall=null;
    pall="all"; dall="99"; yall="1900";
    String progcode=request.getParameter("programname");
    String dcode=request.getParameter("departmentname");
    String yr=request.getParameter("year");
    deptcode=Integer.parseInt(dcode);
    int year=Integer.parseInt(yr);
    boolean flag=false;
    %> <%= progcode%><%=" "+ dcode%><%= " "+yr%><br>
    <%= pall%><%=" "+dall%><%=" " +yall%><br>
    <%= progcode%><%= deptcode%><%= year%>
    <%
    if((!(progcode.equals(pall))) && (!(dcode.equals(dall))) && (!(yr.equals(yall))))
    stmt=con.createStatement();
    rs=stmt.executeQuery("select * from data where progcode='"+progcode+"' and deptcode='"+deptcode+"' and year='"+year+"' ");
    flag=false;
    if(rs!=null){
    if(rs.next()){
    flag=true;
    if(flag){
    gpcode=rs.getString("progcode");
    gdcode=rs.getInt("deptcode");
    gyear=rs.getInt("year");
    gdata=rs.getInt("totalnoofstud");
    stmt1=con.createStatement();
    ResultSet trs=stmt1.executeQuery("select * from program where progcode='"+gpcode+"' ");
    if(trs.next()){
    pname=trs.getString(2);
    stmt2=con.createStatement();
    rs=stmt2.executeQuery("select * from department where deptcode='"+gdcode+"' ");
    if(rs.next()){
    dname=rs.getString("deptname");
    else {
    response.sendRedirect("viewdata.jsp?flag=false");
    stmt=con.createStatement();
    rs=stmt.executeQuery("select sum(totalnoofstud) from data where progcode='"+progcode+"' and deptcode='"+deptcode+"' ");
    if(rs.next()){
    total=rs.getString(1);
    stmt=con.createStatement();
    rs=stmt.executeQuery("select sum(totalnoofstud) from data where year='"+gyear+"' ");
    if(rs.next()){
    totalyr=rs.getString(1);
    else{
    stmt=con.createStatement();
    rs=stmt.executeQuery(" select sum(totalnoofstud) from data ");
    if(rs.next())
    gtotal=rs.getString(1);
    %>
    <html>
    <head><title>Passed Out Student Data</title></head>
    <body background="foggy2.jpg">
    <br><br>
    <%
    if(progcode!=pall && dcode!=dall && yr!=yall){%>
    <%@ include file="getdatasingle.jsp" %>
    <%}
    else{%>
    <br><br><br><center><b><font color="maroon" size=+3>Total Number Of Students Passed Out Till Now Are </font><font color="red" size=+3><%=" "+ gtotal%><
    /font></b></center>
    <%}%>
    <center>
    <input type="submit" name="ok" value="OK">
    </center>
    </body>
    </html>
    Regards,
    Madhavi

  • Can someone help me correct this sql statement in a jsp page?

    ive been getting the java.sql.SQLException: Incorrect syntax error for one of my sql nested statements. i cant seem to find similar egs online, so reckon if anyone here could help, really appreciate it.
    as im putting the nested sql in jsp page, it has to be with lots of " " n crap. very confusing if there are nested.
    heres the sql statement without those "" that i want to use:
    select top 5 * from(
    select top+"'"+offset+"'"+" * from prod where cat=" +"'" cat "'"+"
    )order by prodID desc
    when i put this in my jsp pg, i had to add "" to become:
    String sql = "select top 5 * from("+"select top"+"'"+offset+"'"+" * from prod where cat=" +"'" +cat+ "'"+")order by prodID desc";cat=" +"'" cat "'"+")order by prodID desc";
    all those "" are confusing me to no end, so i cant figure out what should be the correct syntax. the error says the syntax error is near the offset.

    If offset is, say, 10, and cat is, say, "new", then it looks like you're going to produce the SQL:
    select top 5 * from(
      select top '10' * from prod where cat='new'
    )order by prodID descThat looks exactly like incorrect syntax to me... top almost certainly can't handle a string literal as its operand... you almost certainly would want "top 10" instead of "top '10'"...
    If you use PreparedStatement, you don't have to remember what you quote and what you don't and you can have your SQL in a single static final string to boot...

  • Need help in writing a .jsp page

    Hi Guys,
    I am new to JSP. My requirement is " I have a link on my webpage. When the user clicks that link, a HTML page is displayed which has parameters to be entered (for ex: from_date , to_date). When the user clicks the submit button, a jsp page should be displayed in which a query is run to display the output. For example, the user enters the from_date and to_date parameter values to know the employees employed within those dates in their company. The query is "select empname,empno,sal,dept,comm from emp where employed_date between from_date and to_date" . The following should run and display in the jsp page.
    How can i write a .jsp to extract the parameters that are entered in the HTML form in to a .jsp and run the query with those parameters to display the output. Help needed in making me write this .jsp for this query.
    Help Aprreciated.
    Thanks

    Hm, your requirements sound like homework assignment from classroom. If so, is itn't better that you find the answer youself? There are plenty of very relevant references for how to use jsp to handle html forms or talk to a rdbms through a jdbc connection. For example, for jsp and html forms, you can google "jsp html forms"; for jsp and sql query, search for "jsp jdbc".
    Tell me if this is not helpful.

  • In JSP pages request.getParameter returns null

    There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
    Code :Ist jsp
    <BODY>
    <HEAD>
    function validate()
    document.add.submit();
    </HEAD>
    <FORM name="add" method="post" action=/dir/two.jsp" >
    <TABLE width="37%" border="0" align="center" class="c4f3">
    <TR>
    <TD class="c4">Rating</TD>
    <TD><input type=text name="rating"></TD?
    </TR>
    <TR>
    <TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    After the submit it goes to the 2nd JSP page .
    code:2nd Jsp
    <%
    String Rating=request.getParameter("rating");
    out.println(" Rating "+Rating);
    %>
    The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
    Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
    Thanks

    If I'am right you have misplaced the opening body-tag of your first jsp-page.
    The opening body-tag should follow after the closing head tag .
    The structure of your HTML-code should look like this:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

  • The edit JSP page does not appear...

    Hi!
    I make a simple JSF application, I would like to show a DB table in a h:dataTable component and edit a given row after click, but the edit JSP page does not appear. I click the on link in the table, but the list is loaded again and not the edit page...:(
    (no exception in application server console)
    Please help me!
    my code:
    **************************************** listmydata.jsp***************************
                   <h:dataTable
                             value="#{myBean.myDataList}"
                             var="myDataItem"
                             binding="#{myBean.myDataTable}"
                   >
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Ajdi"/>
                             </f:facet>
                             <h:commandLink action="#{myBean.editMyData}">
                                  <h:outputText value="#{myDataItem.id}"/>
                             </h:commandLink>
                        </h:column>
    ********************************* MyBean.java *******************************
    package bean;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.component.html.HtmlDataTable;
    import javax.faces.context.FacesContext;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    import wrapper.MyData;
    public class MyBean {
         private List myDataList;
         private HtmlDataTable myDataTable;
         private MyData myDataItem;
         protected Connection Conn;
         // *********************** actions ***********************
         public String editMyData() {
              myDataItem = (MyData)getMyDataTable().getRowData();
              return "editmydata";
         public String saveMyData() {
              try {
                   updateDataInDB();
              catch (SQLException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              catch (NamingException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              return "listmydata";
         // *********************** setter ***********************
         public void setMyDataList(List myDataList) {
              this.myDataList = myDataList;
         public void setMyDataTable(HtmlDataTable myDataTable) {
              this.myDataTable = myDataTable;
         public void setMyDataItem(MyData myDataItem) {
              this.myDataItem = myDataItem;
         // *********************** getter ***********************
         public List getMyDataList() {
              if (myDataList == null || FacesContext.getCurrentInstance().getRenderResponse()) {
                   loadMyDataList();
              return myDataList;
         public HtmlDataTable getMyDataTable() {
              return myDataTable;
         public MyData getMyDataItem() {
              return myDataItem;
         // *********************** others ***********************
         public void loadMyDataList() {
              try {
                   getDataFromDB();
              catch (NamingException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              catch (SQLException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
         void getDataFromDB() throws NamingException, SQLException {
              myDataList = new ArrayList();
              java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement("SELECT id, name, value FROM BEA_JSF_SAMPLE");
              PreStat.execute();
              java.sql.ResultSet Rs = PreStat.getResultSet();
              while(Rs.next()) {
                   MyData OneRecord = new MyData();
                   OneRecord.setId(Rs.getLong(1));
                   OneRecord.setName(Rs.getString(2));
                   OneRecord.setValue(Rs.getString(3));
                   myDataList.add(OneRecord);
         void updateDataInDB() throws SQLException, NamingException {
              String sql = new String("UPDATE BEA_JSF_SAMPLE SET name=?,value=? WHERE id=?");
              java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement(sql);
              PreStat.setString(1,myDataItem.getName());
              PreStat.setString(2,myDataItem.getValue());
              PreStat.setLong(3,myDataItem.getId().longValue());
              PreStat.execute();
              ownGetConnection().commit();
         Connection ownGetConnection() throws SQLException, NamingException {
              if (Conn == null) {
                   InitialContext IniCtx = new InitialContext();
                   DataSource Ds = (DataSource)IniCtx.lookup("JDBCConnectToLocalhost_CRS");
                   Conn = Ds.getConnection();
              return Conn;
    ******************************* editmydata.jsp *****************************
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <html>
    <body>
    <f:view>
    <h:form>
         <h:panelGrid columns="2">
              <h:outputText value="Name"/>
              <h:inputText id="name" value="#{myBean.myDataItem.name}"/>
              <h:outputText value="Value"/>
              <h:inputText id="value" value="#{myBean.myDataItem.value}"/>
         </h:panelGrid>
         <h:commandButton action="#{myBean.saveMyData}" value="Save"/>
    </h:form>
    </f:view>
    </body>
    </html>

    I have put his lines in the faces-config.xml and now it works:
         <navigation-rule>
              <from-view-id>*</from-view-id>
              <navigation-case>
                   <from-outcome>editmydata</from-outcome>
                   <to-view-id>editmydata.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
         <navigation-rule>
              <from-view-id>*</from-view-id>
              <navigation-case>
                   <from-outcome>listmydata</from-outcome>
                   <to-view-id>listmydata.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    I don't understand, that I define the next JSP page in the bean java file, which must be shown, but I must define this in the faces-config.xml as well.
    for example:
         public String editMyData() {
              myDataItem = (MyData)getMyDataTable().getRowData();
              return "editmydata";
    is it right or Do I make a mistake somewhere?

  • Button action with onclick in a jsp page using Jscript

    hi,
    I am facing a problem in setting an action with a button in a jsp page the error is object does'nt support this function,kindly send me reply as soon as possible.
    Santhosh

    hi,
    I am facing a problem in setting an action with a button in a jsp page the error is object does'nt support this function,kindly send me reply as soon as possible.
    Santhosh

  • JSP page is coming back with old data even when DB updated

    Hello,
    I am updating an existing record on a database using an HTML form and the changes update the ACCESS database immediately, but the .jsp page is picking up
    old data.
    But but when i do a manual REFRESH, the correct data comes back fine!
    Thanks very much for any insights!
    Summary of the code:
    1. InputEmployeeInfo.html - enter change data, call update....jsp
    <HEAD> <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/> </HEAD>
    <FORM NAME="updateInfo"
    ACTION="./UpdateEmployeeInfo.jsp" >>>>>2.
    METHOD="POST">
    2. UpdateEmployeeInfo.jsp: - call bean, update database, forward to present..jsp
    <HEAD> <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    </HEAD>
    <% response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0); %>
    <jsp:useBean id="empInfo"
    class="com.ora.jsp.beans.employee23.EmployeeInfoBean" >>>>>3.
    scope="request"/>
    <jsp:setProperty name="empInfo" property="*" />
    <% empInfo.updateDatabase(); %> >>>>>3b.
    <jsp:forward page="PresentChangeOfEmployeeData.jsp" /> >>>>>4.
    </BODY>
    </HTML>
    3. com.ora.jsp.beans.employee23.EmployeeInfoBean - Bean-update DB with change data
    public class EmployeeInfoBean {
    public void updateDatabase(){                                            <----3b.
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conn =
    DriverManager.getConnection("jdbc:odbc:example");
    String sql = "UPDATE EMPLOYEEINFO SET " +
    "NAME=?, ADDRESS=?, PHONE=? WHERE ID=?";
    PreparedStatement statement = conn.prepareStatement(sql);
    statement.setString(1, name);
    statement.setString(2, address);
    statement.setString(3, phone);
    statement.setInt(4, id);
    statement.executeQuery();
    statement.close();
    conn.close();
    4. PresentChangeOfEmployeeData.jsp - read database and display changes <----4.
    <HEAD> <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    </HEAD>
    <% response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0); %>
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conn =
    DriverManager.getConnection("jdbc:odbc:example");
    Statement statement = conn.createStatement();
    String sql = "SELECT * FROM EMPLOYEEINFO WHERE ID = " + employeeID;
    ResultSet rs = statement.executeQuery(sql);
    while(rs.next()){
    %>
    <TR><TD ALIGN="right" WIDTH="50%">Name:</TD>
    <TD WIDTH="50%"><%= rs.getString("NAME") %></TD>
    ================================================================================
    Complete code listing:
    1, InputEmployeeInfo.html
    <HTML>
    <HEAD>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <TITLE>Change of Information</TITLE>
    </HEAD>
    <BODY>
    <TABLE WIDTH="100%" BORDER="0" BGCOLOR="navy">
    <TR ALIGN="center">
    <TD><FONT SIZE="7" COLOR="yellow">Employee Information</FONT></TD>
    </TR>
    </TABLE>
    <CENTER>
    <FONT SIZE="5" COLOR="navy">
    Please Enter Your Information<BR>
    Fill in all fields
    </FONT>
    </CENTER>
    <TABLE WIDTH="100%">
    <FORM NAME="updateInfo"
    ACTION="./UpdateEmployeeInfo.jsp" >>>>>>>>>2.
    METHOD="POST">
    <TR><TD WIDTH="40%" ALIGN="right">Current ID: </TD>
    <TD WIDTH="60%"><INPUT TYPE="text" NAME="id"></TD>
    </TR>
    <TR><TD WIDTH="40%" ALIGN="right">New Name: </TD>
    <TD WIDTH="60%"><INPUT TYPE="text" NAME="name" VALUE="Mickey"></TD>
    </TR>
    <TR><TD WIDTH="40%" ALIGN="right">New Address: </TD>
    <TD WIDTH="60%">
    <INPUT TYPE="text" NAME="address" VALUE="St. Louis, MO">
    </TD>
    </TR>
    <TR><TD WIDTH="40%" ALIGN="right">New Phone: </TD>
    <TD WIDTH="60%">
    <INPUT TYPE="text" NAME="phone" VALUE="555-555-1234">
    </TD>
    </TR>
    <TR><TD COLSPAN="2" ALIGN="center">
    <INPUT TYPE="submit" NAME="btnSubmit" VALUE="Update Profile"></TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </HTML
    2. UpdateEmployeeInfo.jsp:
    <HTML>
    <HEAD>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <TITLE>Updating Employee Information</TITLE>
    </HEAD>
    <BODY>
    <% response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0);
    %>
    <jsp:useBean id="empInfo"
    class="com.ora.jsp.beans.employee23.EmployeeInfoBean" >>>>>>>>>>>>>3.
    scope="request"/>
    <jsp:setProperty name="empInfo" property="*" />
    <% empInfo.updateDatabase(); %> >>>>>>>>>>>>>3b.
    <jsp:forward page="PresentChangeOfEmployeeData.jsp" /> >>>>>>>>>>>>>4.
    </BODY>
    </HTML>
    3. com.ora.jsp.beans.employee23.EmployeeInfoBean <-------------3.
    package com.ora.jsp.beans.employee23;
    import java.sql.*;
    public class EmployeeInfoBean {
    private String name, address, phone;
    private int id;
    public void setName(String input){
    name = input;
    public String getName(){
    return name;
    public void setAddress(String input){
    address = input;
    public String getAddress(){
    return address;
    public void setPhone(String input){
    phone = input;
    public String getPhone(){
    return phone;
    public void setId(int input){
    id = input;
    public int getId(){
    return id;
    public void updateDatabase(){                                       <-------3b.
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conn =
    DriverManager.getConnection("jdbc:odbc:example");
    String sql = "UPDATE EMPLOYEEINFO SET " +
    "NAME=?, ADDRESS=?, PHONE=? WHERE ID=?";
    PreparedStatement statement = conn.prepareStatement(sql);
    statement.setString(1, name);
    statement.setString(2, address);
    statement.setString(3, phone);
    statement.setInt(4, id);
    statement.executeQuery();
    statement.close();
    conn.close();
    catch (Exception e) {}
    4. PresentChangeOfEmployeeData.jsp <---------4.
    <HTML>
    <HEAD>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <% response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0);
    %>
    <%@ include file="CompanyBanner.html"%>
    <%@ page import="java.sql.*" %>
    <jsp:useBean id="empInfo"
    class="com.ora.jsp.beans.employee23.EmployeeInfoBean"
    scope="request"/>
    <CENTER>
    <FONT SIZE="5" COLOR="navy">
    Your New Information
    </FONT>
    </CENTER>
    <TABLE WIDTH="100%" BORDER="1">
    <%
    int employeeID = empInfo.getId();
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); <--------4b,
    Connection conn =
    DriverManager.getConnection("jdbc:odbc:example");
    Statement statement = conn.createStatement();
    String sql = "SELECT * FROM EMPLOYEEINFO WHERE ID = " + employeeID;
    ResultSet rs = statement.executeQuery(sql);
    while(rs.next()){
    %>
    <TR><TD ALIGN="right" WIDTH="50%">Name:</TD>
    <TD WIDTH="50%"><%= rs.getString("NAME") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Address:</TD>
    <TD WIDTH="50%"><%= rs.getString("ADDRESS") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Phone Number:</TD>
    <TD WIDTH="50%"><%= rs.getString("PHONE") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Work Status:</TD>
    <TD WIDTH="50%"><%= rs.getString("WORKSTATUS") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Total Sick Days:</TD>
    <TD> <%= rs.getString("TOTALSICKDAYS") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Taken Sick Days: </TD>
    <TD><%= rs.getString("TAKENSICKDAYS") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Total Personal Time(in hours): </TD>
    <TD><%= rs.getString("TOTALPERSONALTIME") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Taken Personal Time(in hours): </TD>
    <TD><%= rs.getString("TAKENPERSONALTIME") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Health Care Plan:</TD>
    <TD WIDTH="50%"><%= rs.getString("HEALTHCAREPLAN") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Dental Plan:</TD>
    <TD WIDTH="50%"><%= rs.getString("DENTALPLAN") %></TD>
    </TR>
    <TR><TD ALIGN="right" WIDTH="50%">Vision Plan:</TD>
    <TD WIDTH="50%"><%= rs.getString("VISIONPLAN") %></TD>
    </TR>
    <% }//end while loop
    } // end try block
    catch (Exception e) {};
    %>
    </TABLE>
    <%@ include file="ch24_SiteNavigator.html" %>
    </BODY>
    </HTML>

    <%
    String dept_name=request.getParameter("D1");
    String itmp,itmcd,sn;
    %>
    <%
    Connection con;
    PreparedStatement ps;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:acc");
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select * from item_details where Item_Name='"+dept_name+"'
    %>
    <td> Product name</td>
    <td>Product description</td>
    <td><Product code</td>
    <td>Product price</td></tr>
    <form method=post action="mycreate.jsp">
    <%
    while(rs.next())
    %><tr>
    <%=rs.getString(1)%></td>
    <%=rs.getString(4)%></td>
    <td><font color="#ffffff" size="3" face="arial unicode
    ms">    <%=rs.getString(3)%></td>
    <% String temp=rs.getString(3);%>
    <%=temp%>
    <td>
    <%=rs.getString(5)%></td>
    <td><input type=submit value="Add to cart"></td></tr>
    <form method=post action="mycreate.jsp">
    <%
    con.close();
    %>
    </tr>
    </table></tr></table></tr></table>
    </form>
    </form>
    I want the value of rs.getString(3) in a variable

Maybe you are looking for

  • Text Import Options Menu Box

    I recently created a deck of cards in Illustrator for a design show. All the elements were created in Illustrator CS4 in different files. I started a new file and put the cards together printed and saved my file as usual. a week later I tried to open

  • How do I get address bar to show up on tabs? How do I stop computer from immediately redirecting me to newly opened tab?

    Apologies for my ignorance, first off. I am using a new laptop and want the settings to be the same as those of my former laptop. However, I have no clue how to adjust settings. On my former laptop, the address bar was always displayed on each new ta

  • My computer is slower than usual...

    My mac G4 has gotten slower... it takes more time for files to download or programs to open... (like simple things that used to take no time at all are taking time to load now) and that "beachball" comes out often... what can i do to fix this? also..

  • How to erase all 9 last dialed numbers from a Treo 750

    Dear Friends, Does someone knows how to erase all the last 9 dialed numbers that appears in a Treo 750 when the left green (phone Icon) key is pressed? Just in case, I already tried to erased them using the "Call Log" Menu "delete All Calls" option,

  • Setting user permissions when running commands

    Here's a doosey, Looking to implement a system which will run "commands" being recieved from the network from a bunch of different users. I want the users to have different permissions depending on their username. I'm thinking the backing store as be