Jsp and JPanel problem

Hello. I've been to this forum many times, but have always been a bit gunshy about posting anything of my own. Now I have a problem I haven't seen before, so here goes. I have a JPanel in a java program that has all sorts of other componants added to it. I am trying to display the whole thing in a jsp page. This is what I am doing in the java file to return the image ("display" is the JPanel):
public byte[] getImage(){
    int w = display.getWidth();
    int h = display.getHeight();
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    display.paint(img.createGraphics());
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ImageIO.write(img, "jpeg", os);
    return os.toByteArray();
}and then in the jsp page I say:
<%@ page contentType="image/jpeg" %>
<%@ page import="myPackage.MyClass" %>
<%
     MyClass picture = new MyClass();
     byte[] b = picture.getImage();
     OutputStream os;
     os = response.getOutputStream();
     os.write(b);
     os.flush();
%>And the problem is that the page is displaying a blank JPanel and none of the componants that were added to it. If I save the the JPanel as a jpeg in the java program, though, it does contain all the componants, so I am not sure what I am doing wrong here. If there is some way to get the all the JPanel componants returned, that would be great to know. Thanks for any help.

nope, that didn't work.
Maybe I am going about solving the problem all wrong. The JPanel and its componants are kind of like a template. When a user of the system submits their information it automatically puts the data into the template and displays it on screen as a jpg. It works when I save the jpg as a file from the java program but not when i send the byte array to the jsp server. It just shows the blank panel....
Is there a better way to go about doing this?

Similar Messages

  • JSP and Tomcat Problem

    Folks,
    My apologies if this is off-topic for this forum, but I've been having this problem using Tomcat and JSP. I'm fairly new to Java.
    Basically, I'm writing a webapp that uses servlets and JSP together. The servlet and backend classes all compile fine. Now, basic frontend page is called Console.jsp, and one of the commands that it runs is <%@ page import="DJUser">
    Here's the problem: Console.jsp is in $CATALINA_HOME/webapp/
    DJUser (and the rest of the classes I'm using) are in $CATALINA_HOME/webapp/WEB-INF/classes
    When I attempt to run Console.jsp I get this error:
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    The import DJUser cannot be resolved
    An error occurred at line: 9 in the jsp file: /Console.jsp
    Generated servlet error:
    DJUser cannot be resolved to a type
    An error occurred at line: 11 in the jsp file: /Console.jsp
    Generated servlet error:
    user cannot be resolved
    An error occurred at line: 11 in the jsp file: /Console.jsp
    Generated servlet error:
    DJUser cannot be resolved to a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    The ROOT CAUSE is listed as:
    java.lang.ClassNotFoundException: org.apache.jsp.Console_jsp
         java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         java.security.AccessController.doPrivileged(Native Method)
         java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
         org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596)
         org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    I'm running Tomcat 5.5.12 on Mac OS X 10.4. Could this be a permissions issue somehow? For right now (testing purposes only) I have tomcat running under my (non root) account.
    I've been scouring the web for a while, and I can't really find anything on this. I'd appreciate any help you could give me.
    Thanks!
    Dylan

    Put the DJUser java file in a package (say com.myClasses) and recompile. Then put the DJUser class file under the WEB-INF/classes directory in the proper package structure (WEB-INF/classes/com/myClasses/DJUser). Stop and restart the server to pick up the new classes. Make sure to change the jsp import statement ( <%@ page import="com.myClasses.DJUser">)

  • Jsp and javascript problem

    I have a JSP page with a table of n rows. Each row has the option of having
              a dropdown list appear on that particular row. The user should have the
              ability to make a selection from the drop down list and have the page change
              to the correct page automatically or it can allow the user to change and
              have them click on a link that passes the value of the select box as a
              parameter to the proper page.
              The problem is that each row CAN NOT be in it's own form. The action for
              the current form is NOT the action I want the select box to use.
              I can't seem to figure out how to get the value of the select box in
              javascript passed as a parameter using a JSP variable.
              Example code:
              <form method="post" action="/index.jsp">
              <table>
              <tr>
              <td> Remove Row? </td>
              <td> View Options? </td>
              <td> Name </td>
              </tr>
              <tr>
              <td> <input type=checkbox name='<%=rowNumber %>' value='<%=
              someCheckboxValue %>'> </td>
              <td> <select name=selectOptions>
              <option value="option 1">option1</option>
              <option value="option 2">option2</option>
              <option value="option 3">option 3</option>
              </select>
                View Option  
              </td>
              <td> <%= rowName %> </td>
              </tr>
              <tr>
              <td colspan="3"> <input type=button name='UpdateExampleForm'
              value='Submit'> </td>
              </tr>
              </table>
              </form>
              

    actually i am taking menus from database in file ourmenu.jsp
    and i have another file called menu.js which displays the menus on browser
    menu.js is the file which i have downloaded from net
    and i want to use at it is but with a difference that it should display the menus which r coming from database
    in file ourmenu.jsp i have saved the menus in array so can anyone tell me how to refer them in my .js file.
    i have tried with foll. code::
    var aUsername =new array();
    <% i=0;
    while (padtemp[i] != null)
    %>
    aUsername[<%= ++i%>] = "<%= padtemp[i] %>";
    in .js file but i am getting no o/p on browser
    i have tried with runat=server while including the .js file in .jsp file but its not working too.
    can anyone help please
    thanks in advance

  • Jsp and JavaBean problem

    Hi All,
    I need UR help
    Problem:
    I have a javaBean and a jsp page say test.class and test.jsp respectively.
    Now the problem is when i run my jsp in web browser with path
    http://localhost:8080/mypackage/test.jsp and use test.class in it. It give me an error Class test.class Not Found but when i give the path http://localhost:8080/examples/jsp/parentpackage/mypackage/test.jsp
    it works fine.
    I am using Tomcat 3.2 and i have already made changes in server.xml for my jsp files thats why i can run my programs with the earlier path but dont know why its giving the error when i use javabean,
    Also i have put my javabean class in---parentpackage/mypackage/test.class
    Thanks
    Amit

    hi there,
    Thanks for you time, here i have placed the source for jsp and javabean
    Please excuse me if you find the code unproper
    Code for JSP:
    <%
    response.setHeader("Pragma","No-cache");
    response.setDateHeader("Expires",0);
    response.setHeader("Cache-control","No-cache");
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Internal Clarification-Agent View</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body background="images/c.jpg" bgproperties="fixed">
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" session="true"%>
    <%@ page import="java.util.Date" %>
    <%@ page import="java.sql.Timestamp" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="javax.servlet.http.*"%>
    <jsp:useBean id="navi" class="arvato.interclarification.rqchunk" scope="session" />
    <%
    try{
    Connection con = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:interdsn","","");
    String qrno = request.getParameter("qrno");
    String rdb = request.getParameter("rb");
    String key = request.getParameter("key");
    String cname = request.getParameter("cname");
    //out.print(key);
    //if(st.equals("All")){
    String sql="";
    if(rdb!=null){
    if(rdb.equals("1")){
    if(qrno==null||qrno.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(qrno!=null){
    sql = "SELECT * FROM crequired WHERE queryno LIKE '"+qrno+"%'";
    }else if(rdb.equals("2")){
    if(key==null||key.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(key!=null){
    sql = "SELECT * FROM crequired WHERE clarification LIKE '"+key+"%'";
    else if(rdb.equals("3")){
    if(cname==null||cname.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(cname!=null){
    sql = "SELECT * FROM crequired WHERE fname LIKE '"+cname+"%'";
    if(rdb==null)
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    ps = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    //ps.setString(1,space);
    /*}else{
    sql = "SELECT * FROM crequired WHERE status=? AND space=?";
    ps = con.prepareStatement(sql);
    ps.setString(1,st);
    ps.setString(2,space);
    ResultSet rs = ps.executeQuery();
    %>
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="50%"><strong><img src="images/microsoftlogo1.jpg" width="288" height="94"></strong></td>
    <td width="50%"><div align="right"><strong><img src="images/logo2.jpg" width="177" height="77"></strong></div></td>
    </tr>
    </table><br>
    <hr noshade color="#000000">
    <div align="center"><font color="#990000" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>CSR
    VIEW</strong></font>
    </div>
    <form name="form" method="post" action="agentview1.jsp">
    <table width="59%" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td width="49%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
    <input name="rb" type="radio" value="1" <%if(rdb!=null){if(rdb.equals("1")){out.print("checked");}}%>>
    <font size="1">SEARCH BY QUERY NUMBER:</font></strong></font></td>
    <td width="51%"><input name="qrno" type="text" id="qrno"></td>
    </tr>
    <tr>
    <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="radio" name="rb" value="2" <%if(rdb!=null){if(rdb.equals("2")){out.print("checked");}}%>>
    <font size="1"> SEARCH BY KEY WORD:</font></font></strong></td>
    <td><input name="key" type="text" id="key"></td>
    </tr>
    <tr>
    <td><input type="radio" name="rb" value="3" <%if(rdb!=null){if(rdb.equals("3")){out.print("checked");}}%>>
    <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">SEARCH
    BY CSR NAME:</font></strong></td>
    <td><input name="cname" type="text" id="cname"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" value="Submit">
    </div></td>
    </tr>
    </table>
    </form><br>
    Back
    <%
    navi.setchunk(10);
    navi.setRS(rs);
    String v="";
    String vv=request.getParameter("off");
    if(vv==null){v="1";}
    else{
    v=vv;
    int i=Integer.parseInt(v);
    navi.setcursor(i);
    ResultSet rs2=navi.getRS();
    int h1=1;
    if(request.getParameter("off")!=null) h1=Integer.parseInt(request.getParameter("off"));
    int h2= navi.getchunk();
    int h3= navi.getcount();
    int offset=(h3-h1)<h2?h3:(h1+h2-1);
    %>
    <table width=100%><tr><td width=33%> </td><td align=center width=34%><font face="verdana, arial" size=2 color=#000000>Displaying <%=h1%> to <%=offset%> of <font size=4><%=h3 %></font></font></td><td width=33%> </td></tr></table>
    <%
    int c1=navi.getcount(),c2=navi.getchunk();
    int c3=navi.getcursor();
    int c4=c3+c2;
    int c5=c3-c2;
    %>
    <table width=100% ><tr><td align=left width=100% >
    <%
    if(c3>c2 && c3<=c1){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c5+"\">Previous</a>");
    %></td><td align=right width=100%>
    <%
    if(c1>c2 && (c1-c3)>=c2){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c4+"\">Next</a>");}
    %>
    </td></tr></table>
    <table width="1359" border="0" cellspacing="1">
    <tr bgcolor="#3C6C84">
    <th width="2%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">S.No.</font></th>
         <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Query No</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Posting Date & Time</font></th>
         <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
    By</font></th>
    <th width="6%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Received
    By</font></th>     
    <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Sub
    Process </font></th>
         <th width="4%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Region</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Status</font></th>     
    <th width="15%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Required OnQuery </font></th>
    <th width="18%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Solution</font></th>
    <th width="8%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Visited On</font></th>
    <th width="7%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Closed On</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Remarks</font></th>
    </tr>
    <%
    int m = 0;
    for(int l=0;l<c2 && i<=c1;l++,i++){
    //while(rs.next()){
    m = m+1;
    String queryno = rs.getString("queryno");
    //out.print(queryno);
    %>
    <tr>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=m%></b></font></td>
         <td width="5%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=queryno%></b></font></td>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <%Date d1 = rs.getDate("adate");
         String dd1="";
         SimpleDateFormat sddf = new SimpleDateFormat("MM/dd/yyyy");
         dd1 = sddf.format(d1);
         Date t1 = rs.getTime("atime");
         String tt1="";
         SimpleDateFormat stdf = new SimpleDateFormat("HH:mm");
         tt1 = stdf.format(t1);
         String ttm = dd1+" "+tt1;
         out.print(ttm);     
         %></font>
    </td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <b><%String fnm = rs.getString("fname");
    String lnm = rs.getString("lname");
    String nm = fnm+" "+lnm;
    out.print(nm);
    %></b></font></td>
    <td width="6%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         String tnm = rs.getString("tname");
         if(tnm.equals("null")||tnm.equals("-")){}else{out.print(tnm);}
         %></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=rs.getString("space")%></b></font></td>
         <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%String rg = rs.getString("region");
         if(rg==null||rg.equals("null")){}else{out.print(rg);}%></b></font></td>
         <%String status = rs.getString("status");
         if(status.equalsIgnoreCase("New")){%><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td>
         <%}else if(status.equalsIgnoreCase("Open")||status.equalsIgnoreCase("Awaiting MS Reply")){%><td bgcolor="#FFCC33"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}else{%><td bgcolor="#00CC00"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}%>
    <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#0000CC"><%=rs.getString("clarification")%></font></td>
         <%
    //String queryno = rs.getString("queryno");
    String qry1 = "select * from csolution where queryno=?";
    ps1 = con.prepareStatement(qry1);
    ps1.setString(1,queryno);
    ResultSet rs1 = ps1.executeQuery();
    while(rs1.next()){%>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=rs1.getString("solution")%></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dp = rs1.getDate("dateofopen");
         String dp1="";
         SimpleDateFormat spdf = new SimpleDateFormat("MM/dd/yyyy");
         dp1 = spdf.format(dp);
         Date tp = rs1.getTime("timeofopen");
         String tp1="";
         SimpleDateFormat stpf = new SimpleDateFormat("HH:mm");
         tp1 = stpf.format(tp);
         String tpm = dp1+" "+tp1;
         out.print(tpm);
         %></font>
    </td>
         <td width="5%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dc = rs1.getDate("dateofclose");
         String dc1="";
         SimpleDateFormat scdf = new SimpleDateFormat("MM/dd/yyyy");
         dc1 = scdf.format(dc);
         Date tc = rs1.getTime("timeofclose");
         String tc1="";
         SimpleDateFormat stcf = new SimpleDateFormat("HH:mm");
         tc1 = stcf.format(tc);
         String tcm = dc1+" "+tc1;
         out.print(tcm);
         %></font>
    </td>
         <td width="16%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%String remarks = rs1.getString("remarks");
         if(remarks==null){}else{out.print(remarks);}
         %></font></td>
    <%}navi.setcursor();
    }con.close();}catch(Exception e){out.print(e);}%>
    </tr>
    </table><br>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Back to
    Main Menu</font>
    </body>
    </html>
    Code for javaBean:
    package arvato.interclarification;
    import javax.servlet.http.*;
    import java.sql.*;
    public class rqchunk
              ResultSet rs=null;
              int chunk=5;
              int count=0;
              int cursor=1;
              public rqchunk(){}
              public void setRS(ResultSet rset) throws SQLException
                   rs = rset;
                   int cnt=0;
                   while(rs.next())
                        cnt++;
                   rs.absolute(1);
                   count=cnt;
              public void setcursor()throws SQLException
                   cursor++;
                   rs.absolute(cursor);
              public void setcursor(int i)throws SQLException
                   cursor=i;
                   rs.absolute(cursor);
              public int getcursor()
                   return cursor;
              public int getchunk()
                   return chunk;
              public void setchunk(int i)
                   chunk=i;
              public void setcount(int j)
                   count=j;
              public int getcount()
                   return count;
              public ResultSet getRS()
                   return rs;
              public void clearRS()
                   cursor=0;
                   rs=null;
    Please excuse me if my codes are not understandable enough
    Thanks
    Amit

  • JSP AND BEAN PROBLEm   java.lang.nullpointerexception   help me please

    hello i have a problem, when i open login.jsp and enter the form i have nullpointerexception. i don't understand where i wrong... i use tomcat 5.5 ... sorry for my english i'm italian and i speak only italian :(
    login.jsp this is the code of the java server page
    <html>
    <%@ page language="java" import="java.sql.*" %>
    <jsp:useBean id="lavoro" scope="page" class="Ok.Dino"/>
    <%@ page session="false" %>
    <style type="text/css">
    <!--
    body {
         background-color: #003366;
    a:link {
         color: #CCCCCC;
    .style1 {
         color: #000000;
         font-weight: bold;
         font-size: x-large;
    .style4 {font-size: 18px}
    -->
    </style>
    <body>
    <%if(request.getMethod()=="GET"){
    %>
    <form action="login.jsp" method= "POST" name="frmlogin" id="frmlogin">
         <div align="center">
           <p class="style1">AUTENTICAZIONE</p>
           <p> </p>
           <table width="318" height="140" border="1">
            <tr>
              <td width="95" height="60" bordercolor="#000000" bgcolor="#0066CC"><p align="center"><strong>USER</strong></p>          </td>
              <td width="207" bgcolor="#0099CC"><p align="center">
                <input type="text" name="txtnome"></p>
              </td>
            </tr>
            <tr>
              <td height="72" bordercolor="#000000" bgcolor="#0066CC"><strong>PASSWORD</strong> </td>
              <td width="207" bgcolor="#0099CC"><div align="center">
                <input name="pwdtxt" type="password">
              </div></td>
            </tr>
          </table>
           <table width="318" border="1">
            <tr>
              <td width="318" height="87"> <div align="center">
                <input name="submit" type="submit" value="invia"  >
              </div>
              <p align="center"><strong><span class="style4">Se non sei registrato fallo <a href="file:///C|/Documents and Settings/access/Documenti/My Received Files/registrazione.jsp">adesso </a></span></strong></p></td>
            </tr>
          </table>
           <p> </p>
           <p> </p>
      </div>
    </form>
    <%}else {  %>
    <%lavoro.settxtnome(request.getParameter("txtnome"));%>
    <%!ResultSet rs=null;
         String x=null;
    %>
    <% lavoro.cn_db("dbutenti");%>
    <% rs=lavoro.run_query("SELECT user FROM utenti");%>
    <%}%>
    </body>
    </html>and this is the bean code
    package Ok;
    import java.sql.*;
    public class Dino
    private String txtnome,pwdtxt;
    private Connection cn=null;
    private Statement st=null;
    private ResultSet Rs=null;
    public String gettxtnome()
    return txtnome;
    public String getpwdtxt()
    return pwdtxt;
    public void settxtnome(String n)
    this.txtnome=n;
    public void setpwdtxt(String n)
    this.pwdtxt=n;
    public void cn_db(String db)
              if(cn==null){
              //1. Caricamento del driver
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              }catch(ClassNotFoundException cnfe){
                   System.out.println("impossibile caricare il driver");
                   System.exit(1);
              try{
                   //2. Connessione al DB
                   cn = DriverManager.getConnection("jdbc:odbc:"+db);
                   //3. creazione degli oggetti Statement e ResultSet
                   st =cn.createStatement();
              }catch(SQLException e){
                   System.out.println(e+"jjj");
    }else{
         System.out.print("errore database gi�� creato");
    public ResultSet run_query(String qr)
         try{
    Rs=st.executeQuery(qr);
         }catch(SQLException e)
         System.out.print(e+"ecco l'error");
         return Rs;
    }

    Do you understand when a NullPointerException will be thrown? This will be thrown if you want to access an uninstantiated Object.
    So look to the stacktrace and go to the line where the NPE is been thrown and doublecheck if the object reference is actually instantiated.
    Or add a null-check to the object reference:if (someObject != null) {
        someObject.doSomething();
    }or just instantiate it:if (someObject == null) {
        someObject = new SomeObject();
    someObject.doSomething();

  • Jsp and db2 problem

    Hi guys:
    I installed tomcat4, db2 run time client on one red hat 7.2. Everything works fine. My jsp can access db2 database.
    Now I am installing the same thing into another box, red hat 7.2, tomcat4 and db2 run time client.
    I can write a java code to access the db2 database, and I can access db2 table in the command line. Jsp file is running fine. But when I use the jsp code which is working in another red hat box to access the db2 database, it can not go through and it stops in "Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");" statement.
    Does any body have any idea what could be the problem?
    Regards,
    David

    hi,
    could you please send me the jsp-db2 connection code.i am really distressed.i can't find it anywhere..must i install db2 run client. i have only db2 personal edition and the rest( tomcat,jre,jsdk,etc..)
    Thx
    (while tipping my e-mail in registration,i wrote it false)
    My treu e-mail is [email protected]
    please please send me this code....

  • JSP and Java Beans with Database Problem

    hellow, this is my first posting and i hope to help me as fast as you can...
    my problem is simplly i cant get any data from the database (whatever the database it is, i test it with MS Access and MySQL server) when i use a bean, But if i put my connection statement in the JSP file thair is no problem... ???? !!!!
    for example i have a class "Authentication" that have a method to test if the username and password is correct or not and return 1 if true, 0 if false, -1 if thair are some problem in connecting DB.
    now if i create a normal java application that uses this method, it's work and no problems, BUT if i used a JSP page to use this method it's return allways -1

    T1 class:
    package VX;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    public class T1
    //public MBJDBConnection(String driver,String url)
    public T1()
    JDBC_DRIVER = "com.mysql.jdbc.Driver";//driver;
    DATABASE_URL = "jdbc:mysql://localhost:3306/rawafed?user=root;password=0000";//url;
    //=======DB CONNECTION===========================================
    private static String JDBC_DRIVER;
    private static String DATABASE_URL;
    protected Connection connection;
    protected Statement statement;
    //===========End DBC==============================================
    public int update(String sqlUpdate)
         int i=0;
              //connectDB();
              try{
                   i=statement.executeUpdate(""+sqlUpdate);
                   catch(Exception e)
                        System.out.println("Error Inserting Statement Or Connection Not Opened");
              //disconnectDB();
         return i;
    public ResultSet select(String sqlQuery)
              //connectDB();
              ResultSet rs;
              try
              {//open try
              rs=statement.executeQuery(""+sqlQuery);
                   return rs;
              }//end try
              catch(Exception e2)
                   //System.out.println("Error Selecting Statement Or Connection Not Opened");
              }//end catch
              //add to array list
         //return resultList;
         return null;
    //------Methods-------
    public void connectDB()
    //===========================Connection===================
    try
    Class.forName(JDBC_DRIVER);
    catch(Exception e)
    System.out.println("Error : FOR NAME");
    try
    connection = DriverManager.getConnection(DATABASE_URL, "root", "0000");
    catch(Exception e)
    System.out.println("Error : DB URL");
    try
    statement = connection.createStatement();
    catch(Exception e)
    System.out.println("Error : CREATE STATEMENT ERROR");
    public void disconnectDB()
    try
    statement.close();
    connection.close();
    catch(Exception e2)
    System.out.println("Error : CAN'T CLOSE DB");
    T2 Class
    package VX;
    // class Person.
    //Required Class : EDC.EDCDB
    import java.sql.*;
    public class T2
         public T2()
              //initialization
         //........................ Attributes .........................
         private String user;
         private String password;
         private T1 db=new T1();
         private ResultSet rs;
         //......................... Methods .........................
         public String getAdmin(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success and he is a regular employee 3: SUCCESS AND HE IS agent
              try
              user=u;
              password=p;
              rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=1");
              if(rs.next())
                   return ""+1;
              else
                   rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=2");
                   if(rs.next())
                        return ""+2;
                   else
                        rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=3");
                        if(rs.next())
                             return ""+3;
                        else return ""+0;
              catch(Exception e){System.out.println("Error \n"+e.getMessage());return ""+e.getMessage()+"\n"+(-1);}
         public int getCard(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success
              user=u;
              password=p;
              try
              db.connectDB();
              rs=db.select("SELECT Card_ID,password FROM Card WHERE Card_ID='"+user+"' AND password='"+password+"'");
              if(rs.next())
                   return 1;
              return 0;
              catch(Exception w)
                   return -1;
              finally
                   //System.out.println("Done");
                   db.disconnectDB();
         public int getAny()
              return 1;
    }//end class
    This is a tested class and it's work OK
    import VX.T2;
    public class T3
         public static void main(String [] args)
              System.out.println("System Started...");
              try
                   T2 t2=new T2();
                   System.out.println(t2.getCard("1","a"));
              catch(Exception e)
                   System.out.println("Opsssss ...");
    Now this is the JSP Code that OK and Run without any problems
    <%@ page contentType="text/html; charset=windows-1256" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
    <title>test</title>
    </head>
    <body>
    <%
    //Mazin B. Jabarin 20210464
    //Testing JSP - MySQL Server Driver
    String connectionURL = "jdbc:mysql://localhost:3306/EDCDB?user=root;password=0000";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <%
    try{
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "0000");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM a");
    while (rs.next()) {
    out.println(rs.getString("id")+"<br>");
    rs.close();
    catch(Exception e)
    out.print("Error : "+e.getMessage());
    %>
    </body>
    </html>
    Now this JSP File always returns (-1) ???? !!!!!!!
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" import="VX.T2" import="java.util.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
    try
    T2 t2=new T2();
    out.println("Result Still : "+t2.getCard("1","a"));
    catch(Exception w)
    out.println("<BR> Error In Execution ??? "+w.getMessage());
    %>
    </body>
    </html>
    ++++++++++++++++++++++++++++
    any one can help me please :(
    i use tomcat as web-application
    and i install jdk 1.5
    also JBulder 7
    (now i supposed that the JBulder make some conflict, so i uninstalled it but still Not Working) ...
    before one year i was working just like this way and it was working
    but now i dont know what is the problem
    i am really need help.

  • I want to make a chatroom using jsp, and have some problem, Help!

    I want to build a chatroom using jsp and client using plain html, so i need every client could have a constant connection with the web server and will receive messages realtime. But i got 2 problems.
    First, how can i turn my buffers off so that messages can get to the client the time it is meant to be. I added
    <@page buffer="none">
    but seems that it takes no effect, any tricks here? thx
    Second, I want every user could have a constant conn. with server but i dont want my server to waste resources on those connection that has already been disconnected.so is it possible to stop executing JSP pages once client has diconnected.Since i found that it will throw no exception writing to the client even if the connection is disconnected in JSPs.
    Thanks!!!!!

    By theway, i'm using TOMCat 5.0 as my JSP container.

  • COMMIT problem in TopLink, Struts, JSP and ADF Databinding sample

    In the sample Developing a J2EE Application using TopLink, Struts, JSP and ADF Databinding,
    I followed all the steps to build a department browse page and a edit page.
    But when I get to Step number 23 in "Create a JSP to Edit Departments" I have a problem with the commit.
    Only after I make a change in the form and click the sumbit button, the commit and rollback buttons become active. And After I click the commit button the data gets commited to the database but the page inofmation changes to the very first department record, not the current one.
    How do I make those buttons active with out the extra click on the submit?
    After I click the commit button, how do I keep the current data on the screen?
    Thanks for you help.

    Shay,
    Thanks for the reply.
    For #1, I was able to do the following and get away with not having to press submit first. I just removed the bindings for disable. I hope that does not cause any problems?
    <input type="submit" name="event_Commit" value="Commit" />
    <input type="submit" name="event_Rollback" value="Rollback" />
    For #2, How I add an action on an HTML button? My UIModel.xml for the edit department page currently has two actions on it. Commit and RollBack. Is it linked through the "name" attribute of the input tag?

  • Jsp and image cache problem

    Hello,
    In a jsp(running on tomcat) I switch two jpg files(1.jpg and 2.jpg) and redirect to the page that displays them.
    The problem is that the files are really changed, but the page which displayed them needs manual refresh to "know" they are inter-changed.
    What I have tried, but no success:
    1) In the page which displayed them, I have tried to setup header:
    response.setHeader("cache-control","no-cache, no-store,must-revalidate, max-age=-1");
    response.setHeader("pragma","no-cache, no-store");
    response.setDateHeader ("expires", -1);no difference, in both IE(6 and 7) and Firefox 2.
    Also no result with html:
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">2) I have tried to a add a fake param on the images, like
    <a href="1.jpg?<%=(new java.util.Date()).getTime() %">3) I have tried to add also a fake(time) parameter on the jsp which displayes the images, no result
    How can I force the browser to know that I have inter-changed the images?
    Any idea?
    Thank you.</a>

    to traja47 : could you be more specific about that post? Since there are 30,000 plus post about jsp and my sql, thank you very much.
    to jSweep :
    No exceptions.
    just when i ran it, the page is all empty, then I used the VIEW-SOURCE of IE to see the source of the result page, it showed:
    <html>
    <head>
    <title>Accessing data in a database</title>
    </head>
    <body>
    </body>
    </html>
    all the parts related to java are gone. don't know why.

  • Problems with JSP and MySql bean.

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!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=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!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=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

  • Urgent: problem with sharing HttpSession  object between Jsp and servlets.

    Hi,
              We are using weblogic 6.0 sp2.
              I m setting a particular object in session in a servlet using
              session.setAttribute() but when i try to retrieve that object using
              session.getAttribute() in a jsp page the value of that object is null. Is
              there any way to configure HttpSession in weblogic so that jsps and servlet
              can share the same session? Or any workaround for this problem.
              Any help in this regard is appreciated.
              Thanks
              -Shree
              

    Just a guess, but it sounds like you have cookies turned off and are not
              using encodeURL. Try enabling cookies and see if that solves the problem.
              Also, it is generally good practice to use encodeURL to protect yourself
              from users who disable session cookies.
              Here's how we use encodeURL in our Servlets:
              gotoPage("/jsp/someJSP.jsp");
              private void gotoPage( String address,
              HttpServletRequest request,
              HttpServletResponse response )
              throws ServletException, IOException
              RequestDispatcher dispatcher =
              etServletContext().getRequestDispatcher( response.encodeURL( address ));
              dispatcher.forward( request, response );
              "Shree Unde" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              > We are using weblogic 6.0 sp2.
              > I m setting a particular object in session in a servlet using
              > session.setAttribute() but when i try to retrieve that object using
              > session.getAttribute() in a jsp page the value of that object is null. Is
              > there any way to configure HttpSession in weblogic so that jsps and
              servlet
              > can share the same session? Or any workaround for this problem.
              > Any help in this regard is appreciated.
              > Thanks
              > -Shree
              >
              >
              

  • JSP and package deployment problem in Tomcat 5

    Hi,
    I tried very simple exercise that includes JSP and javabean (from package), but I have the following error:
    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
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    [javac] C:\jwsdp\work\Catalina\localhost\exercises\org\apache\jsp\ex01\ex01_jsp.java:10:
    package pack01 does not exist
    [javac] import pack01.ex01;
    [javac] ^
    Bellow are all my sources
    1. directory structure
    ========================
    C:\jwsdp\webapps\exercises
    index.html
    C:\jwsdp\webapps\exercises\ex01
    build.bat
    ex01.jsp
    C:\jwsdp\webapps\exercises\ex01\WEB-INF
    web.xml
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\classes
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\classes\pack01
    ex01.class
    ex01.java
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\lib
    pack01.jar
    2. sources
    ==========
    << ex01.jsp >>
    <HTML> <HEAD> <TITLE>Ex01</TITLE> </HEAD>
    <BODY>
    <FORM METHOD="GET" ACTION="ex01.jsp">
    <%@ page import = "pack01.ex01" %>
    <H2>Ex01</H2>
    <jsp:useBean id = "x" class = "ex01" scope="application"/>
    </FORM>
    </BODY> </HTML>
    << ex01.java >>
    package pack01;
    import java.io.*;
    public class ex01 implements Serializable {
    private String value;
    public ex01() {
    value = "EX01";
    public void setValue(String s) {
    value = s;
    public String getValue() {
    return value;
    << build.bat >>
    cd WEB-INF\classes\
    cd
    del ex01.jar
    javac -deprecation -verbose pack01\ex01.java
    jar cvf ..\lib\pack01.jar pack01\ex01.class
    << C:\jwsdp\webapps\exercises.xml >>
    <Context className="org.apache.catalina.core.StandardContext"
         cachingAllowed="true"
         charsetMapperClass="org.apache.catalina.util.CharsetMapper"
         configFile="webapps\exercises.xml"
         cookies="true"
         crossContext="false"
         debug="0"
         displayName="Exercises"
         docBase="C:\jwsdp\webapps\exercises"
         domain="Catalina"
         engineName="Catalina"
         j2EEApplication="none"
         j2EEServer="none"
         lazy="true"
         mapperClass="org.apache.catalina.core.StandardContextMapper"
         path="/exercises"
         privileged="false"
         reloadable="true"
         startupTime="30"
         swallowOutput="true"
         useNaming="true"
         wrapperClass="org.apache.catalina.core.StandardWrapper" >
    </Context>
    What is wrong ?
    I have Windows NT and Tomcat 5 (from jwsdp 1.2).
    Thank you,
    Alex.

    I just tried to reproduce the problem with old version of Tomcat (4.0.2) and ... it works. It is definitely specific for Tomcat 5 (or may be one of the late Tomcat 4 as well). There is another related difference:
    With Tomcat 4 I could create javabean in class subdirectory (default package) and use
    <%@ page import="ex01" %>
    Now with Tomcat 5 I have syntax error in this line.
    This syntax error disappeared when I moved javabean into package pack01.

  • Problem with JSP and Java Servlet Web Application....

    Hi every body....
    I av developed a web based application with java (jsp and Java Servlets)....
    that was working fine on Lane and Local Host....
    But when i upload on internet with unix package my servlets and Java Beans are not working .....
    also not access database which i developed on My Sql....
    M using cpanel support on web server
    Plz gave me solution...
    Thanx looking forward Adnan

    You need to elaborate "not working" in developer's perspective instead of in user's perspective.

  • Deploying a WAR file containing .jsp and servlets (also uses JNI)

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

Maybe you are looking for

  • MobileMe Services has stopped working

    I recently updated iTunes and downloaded iCloud on my PC (with Vista 32-bit), since I use an iPhone and an iPad. Since then, each time I turn on Outlook 2003, a message comes on twice that says: "MobileMe Services has stopped working." I know many pe

  • Can't boot normal.

    Hi , I have this very big and annoying problem. When I press the power key my mac doesn't boot . But when I hold ctrl+alt+left shift for a few seconds he starts up , but then he tries to boot from network , I fixed this by pressing a when it boots. B

  • SetCurrentRow does not set the right class on the new row selected

    This has to do with using setCurrentRow and having spry:select used on the active row to enable selection highlighting. When setting the current row programmatically by invoking setCurrentRow, the row get seccessfully set, but the class is not set to

  • Photos in albums

    How come I can't take my photos from my "camera" or my "all" albums & transfer them to other albums I have set up Is it a setting I have to change

  • Adobe Acrobat 8 professional full verision - where can i download...

    I have my key and case, but cant find my dvd