JSP, Javabean charset problem

I have some JSP pages where I try to dynamically present some drop-down
menus for the users to select values. I use a simple bean to manage it.
The problem is that those values are in non-iso8859-1 charset and I only
get ?????? rendered in the select box. I define an array (inline in the
JSP page as code scriptlet), write all possible (String) options for the
drop-down menu there and in the bean I do some calculations and render
the drop-down menu.
String label[]={"something in iso-8859-7 encoding in here","something in
iso-8859-7 encoding in here","something in iso-8859-7 encoding in here"};
and in the bean I have a for-loop to access this.
The page directive is set to iso-8859-7.
I think there is some kind of transparent translation, that has to do
with Java language, and after the rendering I only get ???? instead of
the correct iso-8859-7 value in the browser.
Any help appreciated.
(Tomcat, Apache web server, JDK 1.3,)
PS: This JSP page is used to submit some data in an Oracle database
(according to the selection of the user in the drop-down box), so I also
use JDBC 1.3, but I don't think that's relevant at all with my problem...
null

I have some JSP pages where I try to dynamically present some drop-down
menus for the users to select values. I use a simple bean to manage it.
The problem is that those values are in non-iso8859-1 charset and I only
get ?????? rendered in the select box. I define an array (inline in the
JSP page as code scriptlet), write all possible (String) options for the
drop-down menu there and in the bean I do some calculations and render
the drop-down menu.
String label[]={"something in iso-8859-7 encoding in here","something in
iso-8859-7 encoding in here","something in iso-8859-7 encoding in here"};
and in the bean I have a for-loop to access this.
The page directive is set to iso-8859-7.
I think there is some kind of transparent translation, that has to do
with Java language, and after the rendering I only get ???? instead of
the correct iso-8859-7 value in the browser.
Any help appreciated.
(Tomcat, Apache web server, JDK 1.3,)
PS: This JSP page is used to submit some data in an Oracle database
(according to the selection of the user in the drop-down box), so I also
use JDBC 1.3, but I don't think that's relevant at all with my problem...
null

Similar Messages

  • JSP & JavaBean: setProperty="*" problems!

    this is my bean:
    package my.mine;
    public class myBean{
      private String sito;
      private String chiave; 
      private int start;
      private int stop;
      public void setSito(String s){
        System.out.println("sito " + s);
        if(s!=null || !s.equals(""))
          sito = s;
        else
          sito = ""; 
      public String getSito(){       
        return sito;
      public void setChiavi(String s){
        System.out.println("chiave " + s);     
        if(s!=null || !s.equals(""))
          chiave = s;
        else
          chiave = ""; 
      public String getChiavi(){       
        return chiave;
      public void setStart(String s){
        System.out.println("start " + s);   
        if(s!=null || !s.equals(""))
          start = Integer.parseInt(s);
        else
          start = 0;       
      public int getStart(){       
        return start;
      public void setStop(String s){
        System.out.println("stop " + s);   
        if(s!=null || !s.equals(""))
          stop = Integer.parseInt(s);
        else
          stop = 0;       
      public int getStop(){       
        return stop;
    }this is my JSP Test page:
    <jsp:useBean id="testBean" scope="request" class="my.mine.myBean" />
    <jsp:setProperty name="testBean" property="*"/>
    <html>
      <head>
        <title>Test</title>
      </head>
      <body>
        <form method="post" name="myForm" action="Test1.jsp">
        <table>
          <tr>
            <td align="center"> 
              <input type="text" name="start" size="50" maxlength="50" value="10">
              <br>
              <input type="text" name="stop" size="50" maxlength="50" value="20">     
              <br>
              <input type="text" name="chiavi" size="50" maxlength="50" value="chiavi">
              <br>
              <input type="text" name="sito" size="50" maxlength="50" value="sito">
              <br>
              <input type="submit" value="search" name="searchB">                     
            </td>
          </tr>
        </table>
        </form>
      </body>
    </html>      and this is my problem:
    I can correctely set the values of sito e chiavi fields and can right get all' the bean values. I had tried to change the value of the return statement of getStop ande getStart and this two methods can return the values I assigned them.
    The trouble is that I can't set the start and stop variables with the values in the form...does anybody say me why?
    I don't understand!

    solved in this way:
    public void setInizio(int i s[){
      System.out.println("start " + s);     
      start = i;

  • [Gnome - GDM] Locale/Charset Problem

    Hi everybody,
    I´m using Gnome with GDM as Display Manager.
    I got a problem with my keyboard settings, but don´t know why
    The first charset/locale option is set in the /boot/grub/menu.lst
    kernel /vmlinuz26 lang=de locale=de_DE.UTF8 root=/dev.....
    I use a LUKS encrypted /home partition and need a german locale/charset for the passphrase/during bootup.
    The second charset option is in my /etc/rc.conf:
    LOCALE="de_DE.UTF8"
    KEYMAP="de"
    With those settings I got an almost "normal" keyboard behaviour.
    The Umlaut-Character for example arent´t working during bootup or in a tty. In a later started shell inside of Gnome everything works fine.
    The second charset problem is during password input inside GDM. The layout isn´t working right here either.
    I already tried the ./dmrc settings of Language and Keys, but nothing works.
    Anyone got a clue how to fix that?
    Greets
    Flo

    Maybe you can change the subject of this thread, as the issue is not only related to gdm, IMHO.
    I don't get it either. Settings are LOCALE="sv_SE"  and KEYMAP="sv-latin1" in rc.conf and locale -a gives me
    [root@localhost ~]# locale -a
    C
    POSIX
    sv_SE
    sv_SE.iso88591
    swedish
    But something is still wrong, because calling up some manpages gives me
    Cannot open the message catalog "man" for locale "sv_SE"
    (NLSPATH="<none>")
    I ran locale-gen, but I'm pretty lost in this locale business too...

  • Tomcat 4.0.x and JSP / JSTL performance problems.

    Hello everyone,
    I've got a web application where some of my JSP pages are rendering quite slowly. As an example I'll use a JSP page that I wrote for browsing through a user database. It uses two beans...
    1. jobBean - Ensures that all of the required (and correct) beans that will be used for processing the request have been loaded.
    2. browserBean - A basic JavaBean that holds a set of UserBean(s) and other information pertinent to database queries (start, limit, order).
    I'm using Apache Struts to map requests to the appropriate processing modules. Now the problem I'm having is that each request is taking between 1 and 2 seconds to execute. As you can imagine that's not going to allow for very many simaltaneous users. I've tracked the problem down to something JSP related. All of my code executes fairly quickly (I think). It takes about 20-30ms for my code to identify the request, load the requested data from the database, and convert it into a usable format (the browserBean). Here's my code...
    <%@ page contentType="text/html"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <META http-equiv="Cache-Control" content="no-cache">
    <title>
    Browse Users
    </title>
    </head>
    <body>
    <!-- Set up the OrganizationBeans for use -->
    <jsp:useBean id="jobBean" class="com.vacode.jobs.generic.JobBean" scope="session" />
    <jsp:useBean id="browserBean" class="com.vacode.mqdb.beansets.user.UserBrowserBean" scope="session" />
    <!---------------------------->
    <!-- Start Time Logged Here -->
    <!---------------------------->
    <c:if test="${jobBean.currentJob.name != 'BrowseUserJob'}">
         <!-- This page was accessed before everything was properly initialized -->
         <c:url var="browseUser" value="manageUsers.do">
              <c:param name="action" value="browse" />
         </c:url>
         <c:redirect url="${browseUser}" />
    </c:if>
    <form action="manageUsers.do" method="get">
         <input type="hidden" name="action" value="browse">
         <input type="hidden" name="start" value="<c:out value="${browserBean.dummyStart}" />">
         <input type="hidden" name="order" value="<c:out value="${browserBean.order}" />">
         I would like to view
         <select name="limit">
              <c:forEach begin="1" end="5" var="current">
                   <option value="<c:out value="${current*5}" />"
                        <c:if test="${browserBean.dummyLimit == current*5}">
                        selected
                        </c:if>
                   >
                    <c:out value="${current*5}" />
                   </option>
              </c:forEach>
         </select>
         results per page.
         <input type="submit" action="submit">
    </form>
    <c:url var="id" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_ID" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="name" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="firstName" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_FIRST_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="lastName" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_LAST_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="email" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_EMAIL_ADDRESS" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="organization" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_ORGANIZATION_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="status" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_STATUS_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="role" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="ROLE_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <table>
         <tr>
              <td><a href="<c:out value="${id}" />">Id</a></td>
              <td><a href="<c:out value="${name}" />">User Name</a></td>
              <td><a href="<c:out value="${firstName}" />">First Name</a></td>
              <td><a href="<c:out value="${lastName}" />">Last Name</a></td>
              <td><a href="<c:out value="${email}" />">E-Mail</a></td>
              <td><a href="<c:out value="${organization}" />">Organization</a></td>
              <td><a href="<c:out value="${status}" />">Status</a></td>
              <td><a href="<c:out value="${role}" />">User Type</a></td>
         </tr>
    <c:forEach items="${browserBean.beans}" var="bean">
         <tr>
              <c:url var="manage" value="manageUsers.do">
                   <c:param name="action" value="modify" />
                   <c:param name="beanId" value="${bean.userId}" />
              </c:url>
              <td><a href="<c:out value="${manage}" />"><c:out value="${bean.userId}" /></a></td>
              <td><c:out value="${bean.userName}" /></td>
              <td><c:out value="${bean.firstName}" /></td>
              <td><c:out value="${bean.firstName}" /></td>
              <td><c:out value="${bean.email}" /></td>
              <td><c:out value="${bean.organizationName}" /></td>
              <td><c:out value="${bean.statusName}" /></td>
              <td><c:out value="${bean.roleName}" /></td>
         </tr>
    </c:forEach>
    <!-------------------------->
    <!-- End Time Logged Here -->
    <!-------------------------->
    </table>
    <c:url var="next" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="${browserBean.nextPageStart}" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
         <c:param name="order" value="${browserBean.order}" />
    </c:url>
    <c:url var="previous" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="${browserBean.previousPageStart}" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
         <c:param name="order" value="${browserBean.order}" />
    </c:url>
    <c:if test="${browserBean.previousPageStart>-1}">
         <a href="<c:out value="${previous}" escapeXml="false" />">previous</a>
    </c:if>
    <c:if test="${browserBean.nextPageStart>-1}">
         <a href="<c:out value="${next}" escapeXml="false" />">next</a>
    </c:if>
    <br>
    <br>
    Quick Jump To Page:
    <c:forEach varStatus="loopTag" items="${browserBean.pageStartValues}" var="current">
    <c:choose>
         <c:when test="${loopTag.index+1==browserBean.currentPageNumber}">
              <c:out value="${loopTag.index+1}" />
         </c:when>
         <c:otherwise>
         <c:url var="thisPage" value="manageUsers.do">
              <c:param name="action" value="browse" />
              <c:param name="start" value="${current}" />
              <c:param name="limit" value="${browserBean.dummyLimit}" />
              <c:param name="order" value="${browserBean.order}" />
         </c:url>
         <a href="<c:out value="${thisPage}" />"><c:out value="${loopTag.index+1}" /></a>
         </c:otherwise>
    </c:choose>
    </c:forEach>
    <br>
    <br>
    Max Possible Pages: <c:out value="${browserBean.maxNumberOfPages}" />
    <br>
    Current Page: <c:out value="${browserBean.currentPageNumber}" />
    </body>
    </html>I've added comments where I timed my code from (by writing new Date().getTime() to the console). It usually takes between 1 and 2 seconds for that block of JSP to execute. I wrote a test class that should be very similar to the process (iterating over the forEach loop mainly) and it usually executed in 10ms to 20ms.
    I had a look at the servlets that were generated by Tomcat and I noticed that for each <c:url> I used there's about 300 lines of code (with several syncronized() methods). Could this have anything to do with it? If so, what could I do to improve the performance?
    Worth mentioning... The machine I am using is an AMD Athlon 1GHZ with 768MB RAM, 7200 RPM UDMA100 IDE HDD.
    I'm also using Tomcat integrated with a development environment (IntelliJ IDEA).
    Any help that anyone could offer is much appreciated.
    Thanks,
    Ryan

    Can you get acceptable performance if you hack out everything except the browserBean forEach loop? Maybe you are trying to do too much runtime EL evaluation on the page.
    If performance improves, you may want to push the URL construction and startValue computations to a Struts Action and put a bunch of objects on the requestScope (like "id_url", "name_url", "pageStartValue").
    Putting these computations in the Action would avoid having JSTL parse each of the ${} arguments, evaluating the expressions, and using costly reflection to turn ${browserBean.order} into browserBean.getOrder().

  • JSP, JavaBeans and iPlanet 4.1-  Unable to load JavaBean

    I get the following error when trying to access a JavaBean from a JSP page. I have tried just about everything including using the <@page import /> in the JSP page.
    I can get it to run perfectly in Tomcat 3.2 but it must run in iPlanet 4.1. I think the solution should be fairly simple I just can't find it.
    Any help would be greatly appreciated.
    Thanks.
    The exception is as follows (thrown on running the generatePage.jsp linked from index.jsp).
    [29/Nov/2001:16:50:23] info ( 1364): Internal Info: loading servlet /TechCom/generatePage.jsp
    [29/Nov/2001:16:50:23] info ( 1364): JSP: JSP1x compiler threw exception
    org.apache.jasper.JasperException: Unable to load class JspPageLoader
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:183)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:97)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:728)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:190)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:159)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:141)
         at com.netscape.server.http.servlet.NSServletEntity.load(NSServletEntity.java:214)
         at com.netscape.server.http.servlet.NSServletEntity.(NSServletEntity.java:104)
         at com.netscape.server.http.servlet.NSServletRunner.loadServlet(NSServletRunner.java:607)
         at com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:357)
    [29/Nov/2001:16:50:23] warning ( 1364): Unable to locate class: D:\Netscape\Server4\docs\TechCom (java.lang.ClassNotFoundException: D:\Netscape\Server4\docs\TechCom)
    [29/Nov/2001:16:50:23] warning ( 1364): Internal error: Failed to load servlet (servlet=/TechCom/generatePage.jsp)

    To solve this problem you have to:
    include <@page import /> tags importing the JavaBean to be used.
    In the classpath of iPlanet include the directory in which your JavaBeans are placed.
    Also in the classpath of iPlanet include the root directory of you web site containing the JSP's. this should then solve the problem.

  • JSP import statement problem

    Hey, I got confused with all import statement with jsp.
    Here is my problem.
    Folder structure:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\ROOT\WEB\S\A
    This folder contains a.jsp.
    JSP code:
    <%@ page
         language="java"
         import="java.sql.*, MyPackage.DataBase"
         errorPage=". . ."
         contentType="text/html; charset=windows-1251"
    %>
    <%
           Connection connection = null;
         Statement statement = null;
           DataBase dataBase = new DataBase( connection, statement );
    %>
    ...Error message that I get:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: package MyPackage does not exist
    import MyPackage.DataBase;
                       ^
    An error occurred at line: 104 in the jsp file: /WEB/S/A/a.jsp
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a100_jsp.java:147: cannot resolve symbol
    symbol  : class DataBase
    location: class org.apache.jsp.WEB.S.A.a_jsp
           DataBase dataBase = new DataBase( connection, statement );
            ^
    ...How do I import that class so I can use it?
    Do I need to use useBean?
    What do I need to do?
    Thanks

    DataBase class does not extend java.sql.
    I put this into my jsp page
         import="java.sql.*;"
         import="MyPackage.DataBase;" Here is the error message
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: 'class' or 'interface' expected
    import MyPackage.DataBase;;
    ^
    1 error
    ...

  • Jsp-servlet-bean problem

    Please help!
    I have a servlet controller, a javabean for the data and a jsp for the view.
    I cannot get the jsp using
    <jsp:useBean id="pList" class="bbs.PostListCommand" scope="request" />
    to access the bean data
    However, when I access the bean in this way
    <%@ page import="bbs.PostListCommand" %>
    // html
    <% bbs.PostListCommand postList = null;
    synchronized(session){
         postList = (bbs.PostListCommand) session.getAttribute("PostListCommand");
         if (postList == null){ %>
              <H1>Nothing in request scope to retrieve ....</H1>
              <P>
    <%     }
         else{  %>
              <TABLE border="1">
    // etc
    � it works
    Does anyone know why the <jsp:useBean> tag does not find the bean
    I have installed tomcat 4.18 and set the environmental variables etc.
    Directory structure is
    E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
    E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
    Thanks in advance for any help.
    Chris

    GrayMan - Thanks for your help.
    Let me explain my problem in more detail ...
    Background:
    I have some servlet experience, but I am new to jsp - so sorry if this seems trivial to you ...
    I have a book called bitter java by bruce tate from manning.com . I am trying to get the chapter 3 examples to work
    There are three files
    PostListCommand          the bean
    PostListController     the servlet
    PostListResults          jsp
    And a new test file � PostListResults version 2 with scriptlet code to access the bean.
    There are a couple of typos in the downloaded source files, but nothing that causes the main problem of not being able to access the bean data.
    Program flow
    Servlet instantiates new bean
    Bean � gets data from db
    Servlet passes bean to jsp with a forward
    Jsp outputs data
    I have put the files in the directories �
    E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
    E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
    The complete source code for each file is given below.
    1 I have checked the db access � that�s ok
    2 I have also checked reading the bean data back in from the request scope and printing out the results from within the servlet.- ok
    3 I can access the data through a scriptlet (PostListResults version 2), but not with the original PostListResults which uses <jsp:useBean>
    thanks in advance, chris
    PostListController.java
    package bbs;
    // Imports
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    // Import for commands used by this class
    import bbs.PostListCommand;
    public class PostListController
    extends javax.servlet.http.HttpServlet
    implements Serializable {
    * DoGet
    * Pass get requests through to PerformTask
    public void doGet(
    HttpServletRequest request,
    HttpServletResponse response)
    throws javax.servlet.ServletException, java.io.IOException {
    performTask(request, response);
    public void performTask(
    HttpServletRequest request,
    HttpServletResponse response) {
    try {
    PostListCommand postList = (bbs.PostListCommand) java.beans.Beans.instantiate(getClass().getClassLoader(),"bbs.PostListCommand");
    postList.initialize();
    postList.execute();
    request.setAttribute("PostListCommand", postList);
    ServletContext sc = this.getServletContext();
    RequestDispatcher rd =
    sc.getRequestDispatcher("/jsp/PostListResults.jsp");
    rd.forward(request, response);
    } catch (Throwable theException) {
    theException.printStackTrace();
    PostListCommand.java
    package bbs;
    import java.io.*;
    import java.sql.*;
    //import COM.ibm.db2.jdbc.*;
    import java.util.*;
    * Insert the type's description here.
    * Creation date: (07/17/2001 5:07:55 PM)
    * @author: Administrator
    public class PostListCommand {
    // Field indexes for command properties     
    private static final int SUBJECT_COLUMN = 1;
    private static final int AUTHOR_COLUMN = 2;
    private static final int BOARD_COLUMN = 3;
    protected Vector author = new Vector();
    protected Vector subject = new Vector();
    protected Vector board = new Vector();
    // SQL result set
    protected ResultSet result;
    protected Connection connection = null;
    * execute
    * This is the work horse method for the command.
    * It will execute the query and get the result set.
    public void execute()
    throws
    java.lang.Exception,
    java.io.IOException {
    try {
    // retrieve data from the database
    Statement statement = connection.createStatement();
    result =
    statement.executeQuery("SELECT subject, author, board from posts");
    while (result.next()) {
    subject.addElement(result.getString(SUBJECT_COLUMN));
    author.addElement(result.getString(AUTHOR_COLUMN));
    board.addElement(result.getString(BOARD_COLUMN));
    result.close();
    statement.close();
    } catch (Throwable theException) {
    theException.printStackTrace();
    * getAuthor
    * This method will get the author property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getAuthor(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) author.elementAt(index);
    * getBoard
    * This method will get the board property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getBoard(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) board.elementAt(index);
    * getSubject
    * This method will get the subject property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getSubject(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) subject.elementAt(index);
    * initialize
    * This method will connect to the database.
    public void initialize()
    throws java.io.IOException {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    // URL is jdbc:db2:dbname
    String url = "jdbc:db2:board";
    // URL is jdbc:odbc:bitter3board
    String url = "jdbc:odbc:bitter3board";
    // connect with default id/password
    connection = DriverManager.getConnection(url);
    } catch (Throwable theException) {
    theException.printStackTrace();
    * Insert the method's description here.
    * Creation date: (07/17/2001 11:38:44 PM)
    * @return int
    * @exception java.lang.IndexOutOfBoundsException The exception description.
    public int getSize() {
    return author.size();
    PostListResults.jsp
    <HTML>
    <HEAD>
    <TITLE>Message Board Posts</TITLE>
    </HEAD>
    <BODY BGCOLOR=#C0C0C0>
    <H1>All Messages</H1>
    <P>
    <jsp:useBean id="postList" class="bbs.PostListCommand" scope="request"></jsp:useBean>
    <TABLE border="1">
    <TR>
    <TD>Subject</TD>
    <TD>Author</TD>
    <TD>Board</TD>
    </TR>
    <% for (int i=0; i < postList.getSize(); _i++) { %>
    <TR> <TD><%=postList.getSubject(_i) %></TD>
    <TD><%=postList.getAuthor(_i) %></TD>
    <TD><%=postList.getBoard(_i) %></TD>
    </TR>
    <% } %>
    </TABLE>
    <P>
    </BODY>
    </HTML>
    PostListResults.jsp version 2 � with scriplet code instead of useBean
    <HTML>
    <%@ page import="bbs.PostListCommand" %>
    <!-- This file was generated by the chris -->
    <HEAD>
    <TITLE>Message Board Posts</TITLE>
    </HEAD>
    <BODY BGCOLOR=#C0C0C0>
    <% bbs.PostListCommand postList = null;
    synchronized(request){
         postList = (bbs.PostListCommand) request.getAttribute("PostListCommand");
         if (postList == null){ %>
              <H1>Nothing in request scope to retrieve ....</H1>
              <P>
    <%     }
         else{  %>
              <TABLE border="1">
              <TR>
              <TD>Subject</TD>
              <TD>Author</TD>
              <TD>Board</TD>
              </TR>
         <% for (int i=0; i < postList.getSize(); _i++) { %>
                   <TR> <TD><%=postList.getSubject(_i) %></TD>
              <TD><%=postList.getAuthor(_i) %></TD>
              <TD><%=postList.getBoard(_i) %></TD>
              </TR>
         <% } %>
              </TABLE>
    <%     }
    }%>
    <P>
    goodnight
    </BODY>
    </HTML>

  • Jsp parameters - url problem

    hello,
    I have a problem with the maximum length of an url.
    I have to submit a parameter (which is a list of elements) from a jsp to a servlet. But, for IE, there's a maximum length of the url and it doesn't allow a such longer parameter (for netscape, it's ok).
    I would like to have a button on my jsp which open another jsp which use the parameter of the first jsp. I have thought to use javabeans but I don't know how to keep a same javabean in several JSPs...
    Can you give me some ideas please ?

    // JSP 1
    <form name=fastaForm action=/EHTDb_interface/servlet/EXHServlet>
    <input type=hidden name=clNames value=<%=clNames%>>
    <!-- clNames is a String of 1 to several hundreds of characters long-->
    </form>
    // SERVLET (/EHTDb_interface/servlet/EXHServlet)
    String clNames = (String) request.getParameter("clNames");
    String redirect = "/result/fasta.jsp";
    Fasta f = new Fasta (clNames);
    request.setAttribute("fasta", f.getFasta());
    RequestDispatcher dispatcher;
    dispatcher=getServletConfig().getServletContext().getRequestDispatcher(redirect);
    dispatcher.forward(request, response);
    //JSP 2
    <% HashMap hmFasta =(HashMap) request.getAttribute ("fasta"); %>

  • Strange thing with tomcat+jsp+javabean

    I use javabean in jsp with tomcat container.if I put the javabean file in a package,then it works well.But if I don't, I means,there are no package clause in my javabean file.then it complaint that org.apache.jsp. error:class not found.
    It is very strange.Of course place the class file I put is right.Do anyone encounter the same problem.I use tomcat4.0.4

    Did you import the classfile? Even if it is not there in a package, you need to import it.
    For example, if you have a Test.java (Test.class) in your web-inf\\classes with out any package statement, then you need to code this in your jsp,
    <%@ page import="Test" %> (I don't exactly remember whether you need to import 'Test' or 'Test.class'). Just give a try.
    Sudha

  • Javabean Refresh Problem

    HiHi,
    I have got a problem of refreshing a modified java program.
    I have created a javabean before, there are three fields are defined as float type.
    However, I have got some problem of using float, so I made a change on it to double.
    At the same time, there is a jsp program using this java program. After I compiled the
    java program and put it into the server side (weblogic). I found that there is a probelm
    "NoSuchMethodError" every time when I call the jsp. Then I press space of that jsp
    program and actually made no change of it. And put it into the server
    side again, since there is always a refreshing problem of both java and jsp program
    in weblogic. But I still failed, so I rename both the java and jsp program and try it. Finally the
    same problem still happens.
    So I dunno that it is really a refreshing problem or something I have done wrongly.
    Could anyone help me? Thank you very much!
    Betty

    restart you server and see ...
    when ever you change your javabean you have to restart the server, bcoz the class gets loaded in to the server, once you start it, so, if you change it, it is not going to be changed in the server where the class gets loaded, so, it still has the old copy, so, you have to restart the server for it to reflect the changes ....

  • JSP-JavaBeans Vote Poll

    I made this thread a year back and I didn't get help that I wanted. I need to create a voting poll that has three choices for computer games that the user can choose from. each of these choices is a radio button. After making a choice, the user clicks vote, which should then show below:
    1)How many total votes have taken place
    2)Display the individual votes for each of the 3 choices and then show a percentage of total votes for each of the 3 choices. The following is an example of what this part should look like:
    Votes: 1 Computer Game 1 Percentage total: 100%
    If there were three votes, one for each of the game choices:
    Votes: 1 Computer Game 1 33%
    Votes: 1 Computer Game 2 33%
    Votes: 1 Computer Game 3 33%
    Total Votes: 3
    This is the format for the project. This is the JSP page I have created so far with no connection to a javabean:
    <%@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>
    <table border="1" align="center">
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="red" size="3">
    Computer Voting Poll-Erama</font></td></tr>
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="red" size="3">
    What is your favorite computer game?
    </font></td></tr>
    <tr><td width="30%" bgcolor="black"></td>
    <td width="40%" bgcolor="black" align="center">
    <input type="radio" name="cgames" value="Oblivion" checked><font color="red" size="2"> Oblivion </font>
    <input type="radio" name="cgames" value="starwars"><font color="red" size="2"> Star Wars: Empire at War </font>
    <input type="radio" name="cgames" value="finalfantasy"><font color="red" size="2"> Final Fantasy XI: Online </font>
    <input type="submit" value="votebutton" name="Vote">
    </td>
    <td bgcolor="black" width="30%"></td>
    </tr>
    <tr><td bgcolor="black" colspan="3" align="center"><font color="red" size="3">
    </font><font color="white" size="3">Total Votes</font></td></tr>
    <tr><td height="15" bgcolor="red" colspan="3"></td></tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Oblivion</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Star Wars: Empire at War</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Final Fantasy XI: Online</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td height="15" bgcolor="red" colspan="3"></td></tr>
    </table>
    </body>
    </html>
    I have little experience with beans and very little java experience so I'm at a loss for understanding how to make this work. Any examples of code would be very helpful. Thanks.

    Come now, you really don't expect us to believe that you've been working at this for a year with no headway? :)
    Anyway, have you been through the trails that I linked to in your other thread? For JSPs and Servlets? Have a read at the JavaBeans trail [1] while you're at it.
    And if you've got a specific question about some part where you're getting stuck, please post that. Because as of now, it looks like you need help with the whole thing. Please understand that while no one refuses to help you, people will usually not hand out ready made code for you to use. You need to show that you understand what you're doing and have put in effort with your work and are genuinely stuck despite trying.
    Which part are you unable to do? Reading the selected choice? Adding the data to a bean? Displaying the second page?
    [1] http://java.sun.com/docs/books/tutorial/javabeans/
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Master-Detail-Detail JSP/BC4J Sync Problem

    Hi everybody,
    im having a strange problem with my MDD schema in my custom BC4J/jsp page,
    I went through all other topics in the forum but couldnt find any analogue to my specific problem,
    Lets call schema as M->D1->D2
    What I need to do is to navigate my cursor on D1 using a rowkey, the problem is when i use <jbo:ROW ... action="find"> using the rowkey sent by DataEditComponent, it seeks the first row in my data source(in sync with Master) instead of seeking the actual row.
    FYI, the problem disappears when I omit the master ViewObject (normal master detail using D1->D2)
    Any comments appreciated (ofcourse ASAP ;))
    Here is the original code:
    <%@ page language="java" errorPage="errorpage.jsp" contentType="text/html;charset=utf-8" import = "oracle.jbo.html.*, oracle.jbo.JboException"%>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule id="SalesModule" definition="SalesWeb.SalesModule" releasemode="Stateful" />
    <jbo:DataSource id="dsContact" appid="SalesModule" viewobject="SContactView1" rangesize="10" itermode="LastPagePartial"/>
    <jbo:DataSource id="dsOrder" appid="SalesModule" viewobject="SOrderView2" rangesize="10" itermode="LastPagePartial" />
    <jbo:DataSource id="dsItemList" appid="SalesModule" viewobject="SOrderItemView3" rangesize="10" itermode="LastPagePartial"/>
    <%
    RequestParameters params = HtmlServices.getRequestParameters(pageContext);
    boolean doRedirect=false;
    String PageID=this.getClass().getName();
    String sessJboRowkey=(String)session.getAttribute(PageID+"_jboRowKey");
    String paramJboRowkey=(String)params.getParameter("jboRowKey");
    if(sessJboRowkey!=null && paramJboRowkey==null && (params.getParameter("jboEvent")==null || params.getParameter("jboEvent").toString().compareToIgnoreCase("create")!=0))
    paramJboRowkey=sessJboRowkey;
    else
    if(paramJboRowkey!=null)
    session.setAttribute(PageID+"_jboRowKey",paramJboRowkey);
    String masterRowKey=params.getParameter("masterRowKey");
    if(masterRowKey!=null)
    %>
    <jbo:Row id="currRow" datasource="dsContact" action="find" rowkey="<%=masterRowKey%>" ></jbo:Row>
    <%
    %>
    <jbo:OnEvent name="update" datasource="dsOrder" >
    <jbo:Row id="myrow" datasource="dsOrder" rowkey="<%=paramJboRowkey%>" action="Update" />
    <jbo:Commit appid="SalesModule" />
    </jbo:OnEvent>
    <jbo:OnEvent name="create">
    <% if(paramJboRowkey!=null)
    %>
    <jbo:Row id="newrow" datasource="dsOrder" action="createinrange" ><%
    try
    { %>
    <jbo:SetAttribute dataitem="*" /><%
    } catch (JboException ex)
    newrow.remove();
    throw ex;
    } %>
    </jbo:Row>
    <jbo:Commit appid="SalesModule" />
    <%
    } //end if %>
    </jbo:OnEvent>
    <jbo:OnEvent name="delete">
    <jbo:Row id="delrow" datasource="dsOrder" rowkey="<%=paramJboRowkey%>" action="Delete" />
    <jbo:Commit appid="SalesModule" />
    <%
    doRedirect=true;
    %>
    </jbo:OnEvent>
    <%
    if(doRedirect)
    %>
    <jbo:ReleasePageResources />
    <%
    response.sendRedirect((String)params.getParameter("originURL"));
    %>
    <html>
    <head>
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    <LINK REL=STYLESHEET TYPE="text/css" HREF="bc4j.css">
    <TITLE>Edit Order</TITLE>
    </head>
    <body>
    <% if(paramJboRowkey==null)
    %>
    <h3>Edit Order</h3>
    <jbo:DataEdit datasource="dsOrder" enctype="application/x-www-form-urlencoded" targetURL="SOrderView2_Edit.jsp"/>
    Cancel
    <%
    else
    %>
    <h3>Order Details</h3>
    <jbo:Row id="rowCur" datasource="dsOrder" rowkey="<%=paramJboRowkey%>" action="active">
    <table class="clsViewCurrentRecord" cellspacing="2" cellpadding="3" border="0">
    <jbo:AttributeIterate id="def" datasource="dsOrder">
    <tr class="clsTableRow">
    <td title="<jbo:ShowHint hintname='TOOLTIP'></jbo:ShowHint>"> <jbo:ShowHint hintname="LABEL">##Column</jbo:ShowHint> </td>
    <td title="<jbo:ShowHint hintname='TOOLTIP'></jbo:ShowHint>"> <jbo:RenderValue datasource="dsOrder">##Cell</jbo:RenderValue> </td>
    </tr>
    </jbo:AttributeIterate>
    </table>
    </jbo:Row>
    <%
    %>
    <br>
    <% if(paramJboRowkey!=null)
    %>
    <center>
    <h3>Order Items</h3>
    <table border="0">
    <tr>
    <td ALIGN="right"><jbo:DataScroller datasource="dsItemList" /></td>
    </tr>
    <tr>
    <td><jbo:DataTable datasource="dsItemList" edittarget="SOrderItemView3_Edit.jsp" /></td>
    </tr>
    </table>
    </center>
    <%
    %>
    <jbo:ReleasePageResources />
    </body>
    </html>

    Hi,
    you can use the column- or alias-name of the first query like:
    <dataQuery>
    <sqlStatement name="Q_MASTER">
    <![CDATA[
    select field1,field2 from master_table
    where field3 = 'ABC'
    ]]>
    </sqlStatement>
    <sqlStatement name="Q_DETAIL">
    <![CDATA[
    select field4,field5 from detail_table
    where field6 = :field2 (where field2 is a column of Q_Master)
    ]]>
    </sqlStatement>
    Pay attention that the column-names (aliases) are distinct
    regards
    Rainer

  • Tomcat, JSP,  swedish characters problem

    Hi all,
    I have run into yet another Swedish character problem that I havn't been able to solve. I use Tomcat 5 locally, and Tomcat 4 on a remote server to show my JSPs. When I run the pages locally and enter strings in a form, they show up on other pages with swedish characters looking ok, but when I do it on the Tomcat 4 they are replaced with "?". I set the encoding to utf-8 on each page and the locale is sv_SE.
    Any ideas why?
    BR
    Markus

    This example only sets the default file encoding. You'll have to make sure the charset is not being set in another step of your process.
    On Windows:
    # Place near top of catalina.bat
    set CATALINA_OPTS=-Dfile.encoding=UTF-8
    On Linux:
    # Near top of startup.sh
    CATALINA_OPTS=-Dfile.encoding=UTF-8
    export CATALINA_OPTS

  • Mail attachment charset problem

    Hello,
    I have made a program which is able to send Icalendar files as an attachment. I get the data as an InputStream.
    My problem is that the Icalendar file doesn�t show the letters '�', '�' and '�'. I have tried to use iso-8859-1 in the MimeBodyPart headerline and in the ByteArrayDataSource, but it doesn�t work?!
    Where can I specify which charset I want to use?
    MimeBodyPart mbp3 = new MimeBodyPart();
    mbp3.setFileName( m.getAttachmentFileName() );
    mbp3.setHeader("Content-Class", "urn:content-classes:calendarmessage");
    mbp3.setHeader("Content-ID","calendar_message");
    mbp3.addHeaderLine("charset=iso-8859-1");
    java.io.InputStream inputStream = null;
    try {
          inputStream = m.getAttachmentFile().getBinaryStream();
          mbp3.setDataHandler( new DataHandler( new javax.mail.util.ByteArrayDataSource( inputStream, "text/calendar;charset=iso-8859-1;method=REQUEST" ) ) );
    catch ( Exception e ){}
    mpRoot.addBodyPart(mbp3);

    Yes you are right... Thank you.
    I removed the line:
    mbp3.addHeaderLine("charset=iso-8859-1"); - and now the letters are shown correct when opening the ICalendar file using a text editor.
    But when openning the file using Outlook the letters '�', '�', '�' are removed?! I know that isn�t a problem in my mail code but certainly in the iCal file?!

  • JSP + JDBC + MySql Problem (Tomcat 4.1)

    I'm completely helpless... whenever I try to retrieve stuff from the db (using a jsp page), I get errors that don't even make sense.
    out.println(stmt.executeQuery("SELECT * FROM newsTbl WHERE articleID = 1").getString("articleTitle"));if I try doing the above, I get a "ServletException : Before start of result set" error that supposedly occurred at this line of the generated servlet:
    if (pageContext != null) pageContext.handlePageException(t);---------------
    If i try this:
    ResultSet rsSec = stmt.executeQuery("SELECT * FROM newsSecTbl");
    rsSec.beforeFirst();  //<-- Even if I don't have this line the result does not change
      out.println(rsSec.next());
      while (rsSec.next()) { ... }I the while loop is never initiated, because rsSec.next() is false... kind of weird if you ask me, I even put two entries into the table to make sure the cursor wasnt at the first record and saying there was no second one (which would have been right if there were only one record).
    I would be very grateful if someone could help me out with this. I've never done any db programming with Java yet, so I dont have a clue what Im doing. By the way, I'm using MySql (indicated in the title) and the server was running and available when I ran the above code.
    Cheers,
    Tom

    You can't do this:
    out.println(stmt.executeQuery("SELECT * FROM newsTbl WHERE articleID = 1").getString("articleTitle"));The ResultSet you get back is a database cursor that doesn't point to the first row yet. The correct idiom is:
    String sql = "SELECT * FROM newsTbl WHERE articleID = 1";
    ResultSet result = stmt.executeQuery(sql);
    String articleTitle = "";
    while (result.next())
       title = result.getString("articleTitle");
    result.close();
    stmt.close();If you've never done DB programming before, I'd recommend that you click on the Tutorials link to the left and go through the JDBC tutorial carefully. You'll save yourself a lot of grief.
    Another good idea would be to separate out all your database code into at least one separate object, independent of the servlet. That way you can test and develop it off to the side until it's 100% solid. Then your servlet can simply instantiate one and use it. All your problems from that point forward will be servlet issues, because you'll know that your database code is working. - MOD
    See if that works better. - MOD

Maybe you are looking for