JSP and Database code

Hi All,
To start of I'm just a beginner to JSP.
I've made some JSP pages that get some database info, all works fine but
I do have the database code in the JSP page. And I know that this is not the
ideal method.
I've read that the database code should be seperate from the JSP code, but
how would I do this? Are there any tutorials on the net on how?
Thanks for any help!

Use MVC architecture. There are lot of tutorials available. One of them are in
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html

Similar Messages

  • Please help with jsp and database!!

    Hello,
    i first created a jsp page and printed out the parameters of a user's username when they logged in. example, "Welcome user" and it worked fine...
    i inserted a database into my site that validates the username and password, and ever since i did that in dreamweaver, when a user logs in sucessfully, it returns the jsp page like its supposed to, only that it says "Welcome null" instead of "Welcome John." pretty strange, huh!? can anyone please help? thanks!
    here is the important part of the code to Login.jsp, and LoginSuccess.jsp: <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
    <%@ include file="Connections/Login.jsp" %>
    <%
    // *** Validate request to log in to this site.
    String MM_LoginAction = request.getRequestURI();
    if (request.getQueryString() != null && request.getQueryString().length() > 0) MM_LoginAction += "?" + request.getQueryString();
    String MM_valUsername=request.getParameter("Username");
    if (MM_valUsername != null) {
      String MM_fldUserAuthorization="";
      String MM_redirectLoginSuccess="LoginSuccess.jsp";
      String MM_redirectLoginFailed="LoginFailure.jsp";
      String MM_redirectLogin=MM_redirectLoginFailed;
      Driver MM_driverUser = (Driver)Class.forName(MM_Login_DRIVER).newInstance();
      Connection MM_connUser = DriverManager.getConnection(MM_Login_STRING,MM_Login_USERNAME,MM_Login_PASSWORD);
      String MM_pSQL = "SELECT UserName, Password";
      if (!MM_fldUserAuthorization.equals("")) MM_pSQL += "," + MM_fldUserAuthorization;
      MM_pSQL += " FROM MemberInformation WHERE UserName=\'" + MM_valUsername.replace('\'', ' ') + "\' AND Password=\'" + request.getParameter("Password").toString().replace('\'', ' ') + "\'";
      PreparedStatement MM_statementUser = MM_connUser.prepareStatement(MM_pSQL);
      ResultSet MM_rsUser = MM_statementUser.executeQuery();
      boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
      if (MM_rsUser_isNotEmpty) {
        // username and password match - this is a valid user
        session.putValue("MM_Username", MM_valUsername);
        if (!MM_fldUserAuthorization.equals("")) {
          session.putValue("MM_UserAuthorization", MM_rsUser.getString(MM_fldUserAuthorization).trim());
        } else {
          session.putValue("MM_UserAuthorization", "");
        if ((request.getParameter("accessdenied") != null) && false) {
          MM_redirectLoginSuccess = request.getParameter("accessdenied");
        MM_redirectLogin=MM_redirectLoginSuccess;
      MM_rsUser.close();
      MM_connUser.close();
      response.sendRedirect(response.encodeRedirectURL(MM_redirectLogin));
      return;
    %>
          <form action="<%=MM_LoginAction%>" method="get" name="Login" id="Login">
            <table width="55%" border="0">
              <tr>
                <td width="41%">Username </td>
                <td width="59%"><input name="Username" type="text" id="Username" value="" size="25" maxlength="10"></td>
              </tr>
              <tr>
                <td>Password </td>
                <td><input name="Password" type="password" id="Password" value="" size="25" maxlength="10"></td>
              </tr>
              <tr>
                <td> </td>
                <td><input type="submit" name="Submit" value="Submit"></td>
              </tr>
            </table>
          </form>And LoginSuccess.jsp where i want it to print out the "Welcome username
             <%String Name=request.getParameter("Username");
         out.println ("Welcome ");
         out.println (Name); %>

    <%@ page contentType="text/html; charset=iso-8859-1"
    language="java" import="java.sql.*" %>
    <%@ include file="Connections/Login.jsp" %>
    <%
    // *** Validate request to log in to this site.
    String MM_LoginAction = request.getRequestURI();
    if (request.getQueryString() != null &&
    request.getQueryString().length() > 0) MM_LoginAction
    += "?" + request.getQueryString();
    String
    MM_valUsername=request.getParameter("Username");
    if (MM_valUsername != null) {
    String MM_fldUserAuthorization="";
    String MM_redirectLoginSuccess="LoginSuccess.jsp";
    String MM_redirectLoginFailed="LoginFailure.jsp";
    String MM_redirectLogin=MM_redirectLoginFailed;
    Driver MM_driverUser =
    =
    (Driver)Class.forName(MM_Login_DRIVER).newInstance();
    Connection MM_connUser =
    =
    DriverManager.getConnection(MM_Login_STRING,MM_Login_US
    RNAME,MM_Login_PASSWORD);
    String MM_pSQL = "SELECT UserName, Password";
    if (!MM_fldUserAuthorization.equals("")) MM_pSQL +=
    = "," + MM_fldUserAuthorization;
    MM_pSQL += " FROM MemberInformation WHERE
    E UserName=\'" + MM_valUsername.replace('\'', ' ') +
    "\' AND Password=\'" +
    request.getParameter("Password").toString().replace('\'
    , ' ') + "\'";
    PreparedStatement MM_statementUser =
    = MM_connUser.prepareStatement(MM_pSQL);
    ResultSet MM_rsUser =
    = MM_statementUser.executeQuery();
    boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
    if (MM_rsUser_isNotEmpty) {
    // username and password match - this is a valid
    lid user
    session.putValue("MM_Username", MM_valUsername);
    if (!MM_fldUserAuthorization.equals("")) {
    session.putValue("MM_UserAuthorization",
    ion",
    MM_rsUser.getString(MM_fldUserAuthorization).trim());
    } else {
    session.putValue("MM_UserAuthorization", "");
    if ((request.getParameter("accessdenied") != null)
    ll) && false) {
    MM_redirectLoginSuccess =
    ess = request.getParameter("accessdenied");
    MM_redirectLogin=MM_redirectLoginSuccess;
    MM_rsUser.close();
    MM_connUser.close();
    response.sendRedirect(response.encodeRedirectURL(MM_re
    irectLogin));
    return;
    %>
    <form action="<%=MM_LoginAction%>" method="get"
    "get" name="Login" id="Login">
    <table width="55%" border="0">
    <tr>
    <td width="41%">Username </td>
    <td width="59%"><input name="Username"
    ="Username" type="text" id="Username" value=""
    size="25" maxlength="10"></td>
    </tr>
    <tr>
    <td>Password </td>
    <td><input name="Password" type="password"
    ="password" id="Password" value="" size="25"
    maxlength="10"></td>
    </tr>
    <tr>
    <td>�</td>
    <td><input type="submit" name="Submit"
    me="Submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    And LoginSuccess.jsp where i want it to print out the
    "Welcome username
             <%String Name=request.getParameter("Username");
         out.println ("Welcome ");
         out.println (Name); %>When the page is rediredted u r not passing the user name in the query string,so it is not availble in the query string for LoginSuccess page
    Since u have added user in session user this
    <%String Name=(String)session.getValue("MM_Username") ;%>
    <%     out.println ("Welcome ");
    <%      out.println (Name); %>

  • Jsp and database

    I am new to jsp can anyone tell me what is the best way to connect to database like should I created on java class for that and import it into the jsp

    Yes thats what I do, but set it up to use connection pooling, I am in the process of changing my code to do this and its a bit of a pain, it would be worth you getting it right first time!

  • Beginning Programmer needs help - JSP and databases?

    1. I have never used JSP before, but have been given an assignment to create a webpage to query a database. The database is in Access. Does anyone have a snipet of code in JSP that will query an MS Access database. Is there a function that I can use and pass it an SQL (select statement) and have it return a list of results.
    -OR-
    If there is a way for JSP to transform the MS Access database into a text file that would be good also.
    2. Has anyone created a search functionaly using JSP (or know of a tool) that can search documents, PDF files, HTML files, etc.
    Thank you for any help!

    hi , there is no big deal in JSPs, Servlets, EJBs e.t.c its olnly a matter of committing time and getting urself familar and in areas where you have problems this forum is a nice place for you to share all what u have.
    to start with i will give you some sites where you can start learning jsps, servlets, ejbs and the rest.
    1) http://java.sun.com/j2ee -> look for JSPs , Servlets, EJB, JavaBeans e.t.c
    2) http://www.jspinsider.com
    3) http://www.coreservlets.com
    4) http://www.jakarta.apache.com (download tomcat for your container)
    for databases u can use this code snippet but u will have to read more about databases to be able to chagne some things in this snipper such as your database username, password , url and the rest.
         <%@page import="java.sql.*" %>
         try
            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection ("jdbc:odbc:test_dsn", "sa", "");
         Statement stat = con.createStatement ();
         ResultSet res = stat.executeQuery("select * from authors");
         while (res.next())
              //process the results of this query
         catch (Exception e)
            //process this also
    %>
    You will need to become farmilar with the java programming language and also database conventions so you have a proper understanding.
    study those db codes and modify to suit your needs.
    buzz on me in case you are stuck.
    Regards

  • Jsp and databases

    hello i currently have a jsp page that displays a order number to collect order information.
    The current order number is achived by looking at the previous order number from the database and incrementing 1. The current order number is inserted into the database straight away.
    The problem iam finding is that how should i handle the problem when someone presses the back button in the web browser, this will leave an order number opened in the database without the sumitted order numbers?
    thanks

    Ahh - the classic problem of assigning ids to things.
    So what you are saying is you assign the id when they ENTER the order page, but they leave the page without saving the order, thus you end up with a 'dummy' record in the database - an id, but no good info with it.
    Couple of approaches I can think of
    1 - mark the record as unsaved to begin with, then mark it as saved when the page is submitted successfully. You can then routinely go in and clean out all the 'unsaved' orders. Requires another database field, and you also might have to alter code elsewhere to filter out the unwanted orders.
    This will result in skipped order numbers every time the user 'cancels' saving an order. Are sequential order numbers important to you?
    2 - have a 'pool' of unassigned ids - eg the next 10. Issue them to the user pages on demand. If it doesn't get used in the next 'x' minutes (eg session timeout) issue it again somehow? I dunno - this solution sounds quite complex.
    The only other thing I can think of is to change the time you are assigning the order id to when the user actually saves the order - a whole different kettle of fish. What database are you using? Some support the generation of sequence numbers etc.

  • Example JSP and XML code inside that allows update of attributes

    <?xml version="1.0" encoding="UTF-8"?>
    <MATT_DOCUMENT>
    <NAME>Test MATT Document</NAME>
    <DESCRIPTION>An example MATT Document</DESCRIPTION>
    <TITLE>Matt Australia</TITLE>
    <INCLUDEME>TRUE</INCLUDEME>
    <KEYWORDS>Australia Brisbane Sydney</KEYWORDS>
    <content><![CDATA[<HTML><BODY>Example Document Content</BODY></HTML>]]></content>
    </MATT_DOCUMENT>
    <?xml version="1.0" standalone="yes"?>
    <ClassObject>
    <Name>MATT_Document</Name>
    <Description>A MATT Document.</Description>
    <Superclass RefType="name">Document</Superclass>
    <BeanClassPath>qut.MATT.MATT_Document</BeanClassPath>
    <Attributes>
    <Attribute>
    <Name>TITLE</Name>
    <DataType>STRING</DataType>
    <DataLength>100</DataLength>
    <Required>true</Required>
    </Attribute>
    <Attribute>
    <Name>INCLUDEME</Name>
    <DataType>BOOLEAN</DataType>
    <Required>true</Required>
    </Attribute>
    <Attribute>
    <Name>KEYWORDS</Name>
    <DataType>STRING</DataType>
    <DataLength>500</DataLength>
    <Required>false</Required>
    </Attribute>
    </Attributes>
    </ClassObject>
    /* For information on deploying an instance class bean see iFS Developer's Guide 1.1 Section 4-14 */
    package qut.MATT;
    import oracle.ifs.server.S_LibraryObjectData;
    import oracle.ifs.beans.LibrarySession;
    import oracle.ifs.beans.Document;
    import oracle.ifs.beans.TieDocument;
    import oracle.ifs.common.IfsException;
    import oracle.ifs.common.AttributeValue;
    public class MATT_Document extends TieDocument
    private static final boolean DEBUG = true;
    public static final String CLASS_NAME = "MATT_DOCUMENT";
    public static final String TITLE_ATTRIBUTE = "TITLE";
    public static final String INCLUDEME_ATTRIBUTE = "INCLUDEME";
    public static final String KEYWORDS_ATTRIBUTE = "KEYWORDS";
    public MATT_Document(LibrarySession ifsSession, java.lang.Long id, java.lang.Long classId, S_LibraryObjectData data)
    throws IfsException
    // Construct a Document object - standard variant.
    super(ifsSession,id,classId,data);
    public void setTitle(String newValue)
    throws IfsException
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute(TITLE_ATTRIBUTE,av);
    public String getTitle()
    throws IfsException
    AttributeValue av = getAttribute(TITLE_ATTRIBUTE);
    return av.getString(getSession());
    public void setIncludeMe(boolean newValue)
    throws IfsException
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute(INCLUDEME_ATTRIBUTE,av);
    public boolean getIncludeMe()
    throws IfsException
    AttributeValue av = getAttribute(INCLUDEME_ATTRIBUTE);
    return av.getBoolean(getSession());
    public void setKeywords(String newValue)
    throws IfsException
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute(KEYWORDS_ATTRIBUTE,av);
    public String getKeywords()
    throws IfsException
    AttributeValue av = getAttribute(KEYWORDS_ATTRIBUTE);
    return av.getString(getSession());
    <%-- Copyright 2000 Matt Shannon / Oracle Corporation --%>
    <%-- This page is used for the modification of MATT Document Properties --%>
    <%-- Page Directives --%>
    <%@ page language = "java"
    errorPage=""
    import = "java.util.*, java.text.SimpleDateFormat"
    contentType="text/html;charset=UTF-8"
    info="MATT Document Properties Screen"%>
    <%@ page import = "oracle.ifs.clients.webui.WebUILogin"%>
    <%@ page import = "oracle.ifs.clients.webui.WebUIUtils"%>
    <%@ page import = "oracle.ifs.clients.webui.resources.WebUIResources"%>
    <%@ page import = "oracle.ifs.clients.webui.resources.JspResourcesID"%>
    <%@ page import = "oracle.ifs.clients.webui.FileUtils"%>
    <%@ page i mport = "oracle.ifs.beans.LibrarySession"%>
    <%@ page import = "oracle.ifs.beans.PublicObject"%>
    <%@ page import = "oracle.ifs.beans.Attribute"%>
    <%@ page import = "oracle.ifs.common.AttributeValue"%>
    <%@ page import = "qut.MATT.MATT_Document"%>
    <HEAD>
    <META http-equiv="pragma" content="no-cache">
    <META http-equiv="expires" content="0">
    <%-- Declarations --%>
    <%! final String headingTitle = "MATT Document Properties";
    %>
    <%-- Scriptlet --%>
    <%
    WebUILogin login = WebUILogin.getWebUILogin(request);
    if (login.isTimedOut())
    String msg = "" + WebUIUtils.getResourceString(WebUIResources.WEBUI_SESSION_TIMEOUT_ERROR_CODE);
    msg = msg.replace('\"','\'');
    %>
    <script language="JavaScript">
    alert("<%=msg%>");
    top.close();
    </script>
    <%
    else // if logged in
    String path = WebUIUtils.getBasePathFromServletPath(request,
    WebUIUtils.getUTF8Parameter(request,"path"));
    String container = WebUIUtils.getUTF8Parameter(request,"container");
    String Title = WebUIUtils.getUTF8Parameter(request,"Title");
    String IncludeMe = WebUIUtils.getUTF8Parameter(request,"IncludeMe");
    String Keywords = WebUIUtils.getUTF8Parameter(request,"Keywords");
    String actn = WebUIUtils.getUTF8Parameter(request,"actn");
    LibrarySession sess = login.getSession();
    if (actn == null)
    actn = "";
    if (Title == null)
    Title = "";
    if (IncludeMe == null)
    IncludeMe = "";
    if (Keywords == null)
    Keywords = "";
    if (path.indexOf(":") != -1)
    // path is fine no change
    else if (container.equals("null"))
    path = ":" + path;
    else if (container.endsWith("/"))
    path = container + path;
    else if (path.indexOf(container) == 0)
    // leave path alone
    else
    path = container + "/" + path;
    path = FileUtils.convertPath(path, sess);
    PublicObject pObject = null;
    String displayName = path;
    pObject = WebUIUtils.findPublicObjectByPathOrId(login.getResolver(), login.getSession(),path);
    if (pObject != null)
    pObject = pObject.getResolvedPublicObject();
    if (pObject != null)
    String name = pObject.getName();
    if (name != null && !name.equals(""))
    displayName = name;
    %>
    <title>
    <%= "QUT - " + displayName + " - " + headingTitle%>
    </title>
    <link rel=STYLESHEET type="text/css" href="../webui/css/NewStyles.css">
    </head>
    <body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF0000" alink="#FF0000" onload="store_initial_values()">
    <%
    if (pObject == null)
    %>
    <h3><%=login.getJspResourceString(JspResourcesID.SHOWDOCPROPS_NOT_FOUND_TEXT)%></h3>
    <table>
    <tr>
    <td width="31" height="10" align=left>
    <form>
    <input type="button" name="Button"
    value="<%=login.getJspResourceString(JspResourcesID.WEBUI_OK_BUTTON)%>"
    onclick="top.close();">
    </form>
    </td>
    </tr>
    </table>
    <%
    else // pObject != null
    try
    if (!(pObject instanceof MATT_Document))
    %>
    <h3>Error - Object not an instance of MATT_Document</h3>
    <table>
    <tr>
    <td width="31" height="10" align=left>
    <form>
    <input type="button" name="Button"
    value="<%=login.getJspResourceString(JspResourcesID.WEBUI_OK_BUTTON)%>"
    onclick="top.close();">
    </form>
    </td>
    </tr>
    </table>
    <%
    else
    %>
    <script language="JavaScript1.2">
    var success = true;
    var oldTitle = "";
    var oldIncludeMe = "";
    var oldKeywords = "";
    function store_initial_values()
    oldTitle = document.forms.docPropertiesForm.Title.value;
    oldIncludeMe = document.forms.docPropertiesForm.IncludeMe.selectedIndex;
    oldKeywords = document.forms.docPropertiesForm.Keywords.value;
    function validate_form()
    if (hasChanges())
    document.forms.docPropertiesForm.submit();
    else
    top.close();
    function hasChanges()
    var hasChanged = false;
    var newTitle = " ";
    var newIncludeMe = "";
    var newKeywords = "";
    newTitle = document.forms.docPropertiesForm.Title.value;
    newIncludeMe = document.forms.docPropertiesForm.IncludeMe.selectedIndex;
    newKeywords = document.forms.docPropertiesForm.Keywords.value;
    if (oldTitle != newTitle)
    hasChanged = true;
    else if (oldIncludeMe != newIncludeMe)
    hasChanged = true;
    else if (oldKeywords != newKeywords)
    hasChanged = true;
    return hasChanged;
    </script>
    <%
    if (actn.equals("save_values"))
    try
    // set Title if changed
    if (Title != null && !Title.equals(((MATT_Document)pObject).getTitle()))
    ((MATT_Document)pObject).setTitle(Title);
    // set Keywords if changed
    if (Keywords != null && !Keywords.equals(((MATT_Document)pObject).getKeywords()))
    ((MATT_Document)pObject).setKeywords(Keywords);
    // set IncludeMe if changed
    if (IncludeMe != null)
    boolean l_includeMe = IncludeMe.equals("1");
    if ( ((MATT_Document)pObject).getIncludeMe() != l_includeMe )
    ((MATT_Document)pObject).setIncludeMe(l_includeMe);
    catch (Exception e)
    String msg = "" + login.getErrorResolver().getMessage(e);
    msg = msg.replace('\"','\'');
    %>
    <script language="JavaScript">
    alert("<%=msg%>");
    var success = false;
    history.back();
    </script>
    <%
    } // end catch block
    %>
    <script language="JavaScript">
    if (success)
    document.write("<h2><%=login.getJspResourceString(JspResourcesID.SHOWDOCPROPS_PROPERTIES_SAVED_TEXT)%></h2><form><input type=button value='<%=login.getJspResourceString(JspResourcesID.WEBUI_OK_BUTTON)%>' onclick='top.close();'></form>");
    </script>
    <%
    else // if !actn.equals("save_values")
    %>
    <center>
    <form name="docPropertiesForm" method="POST" action="MATTproperties.jsp">
    <table border="1" width="90%">
    <tr>
    <td width="100%" colspan="3" class="DH">
    MATT Document Class Properties <br>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    Class Name:
    </td>
    <td width="80%">
    <%=pObject.getClassObject().getName()%>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    Bean Path:
    </td>
    <td width="80%">
    <%=pObject.getClassObject().getBeanClasspath()%>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    Description:
    </td>
    <td width="80%">
    <%=pObject.getClassObject().getDescription()%>
    </td>
    </tr>
    <tr>
    <td width="100%" colspan="3" class="DH">
    MATT Document Properties <br>
    </td>
    </tr>
    <tr>
    <td width="15%" class="required">
    Path:
    </td>
    <td width="85%" colspan="2">
    <%=path%>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    Title:
    </td>
    <td width="80%">
    <input type=text name="Title" value="<%=((MATT_Document)pObject).getTitle()%>" size=100>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    Keywords:
    </td>
    <td width="80%">
    <input type=text name="Keywords" value="<%=pObject.getAttribute("Keywords").getString(sess)%>" size=100>
    </td>
    </tr>
    <tr>
    <td width="20%" class="required" align="left">
    IncludeMe:
    </td>
    <td width="80%">
    <select class="listbox" size="1" name="IncludeMe">
    <%
    if (((MATT_Document)pObject).getIncludeMe())
    %>
    <option value="1" selected>true</option>
    <option value="0" selected>false</option>
    <%
    else
    %>
    <option value="1">true</option>
    <option value="0" selected>false</option>
    <%
    %>
    </SELECT>
    </td>
    </tr>
    </table>
    <table width="80%">
    <tr>
    <td width="58" height="10" align =left>
    <input type="button" name="Button" value="<%=login.getJspResourceString(JspResourcesID.WEBUI_OK_BUTTON)%>" onclick="validate_form();">
    </td>
    <td width="62" height="10" align=right>
    <input type="hidden" name="actn" value="save_values">
    <input type="hidden" name="path" value="<%=WebUIUtils.getServletPathFromBasePath(request,path)%>">
    <input type="hidden" name="container" value="<%=container%>">
    <input type="button" name="Button" value="<%=login.getJspResourceString(JspResourcesID.WEBUI_CANCEL_BUTTON)%>" onclick="top.close();">
    </td>
    </tr>
    </table>
    </form>
    <%
    } // end - if actn.equals
    %>
    <%
    } // end - if pObject instance of
    %>
    <%
    catch (Exception e)
    String msg = "" + login.getErrorResolver().getMessage(e);
    msg = msg.replace('\"','\'');
    %>
    <script language="JavaScript">
    alert("<%=msg%>");
    var success = false;
    history.back();
    </script>
    <%
    } // end catch block
    finally
    out.flush();
    } // if pObject
    %>
    <%
    } // if logged in
    %>
    </BODY>
    </HTML>
    There is probably lots of better ways of doing the above. The iFS 1.1 Developer guide confused me alot particularly sections 4-10 and 4-11 where it talks about an instance class bean that extends the Tie classes, then the example shown on 4-12 is completely different!
    note.. also i got most of the above code using JAD having decompiled webui.jar. Seems these JARS are not obfuscated.
    webui.jar in $ORACLE_HOME/ifs1.1/lib
    matt.

    Thanks. I have ifs 1.1 now and have modified this example to use my custom type. However, when the jsp runs and hits the code at the beginning that checks "if login.isTimedOut()", it always thinks I have timed out, even though I have just logged in via the webui.
    Any ideas would be appreciated.

  • JSP and Database connectivity

    Hello!
    I have Tomcat 4.0. and my database file is in Access (emp.mdb)
    I want to connect this Data file from JSP, for that any Driver I have to
    install? like JDBC driver...
    What is the steps and How do I connect? Pl. reply me.
    Thax,
    regards
    mohan

    Dear Amn,
    I am giving sample program. Just change the emp.mdb file path and run this jsp program.
    Then you can see the driver information etc.,
    if you get any problem, please call me at [email protected]. then i will give u solution assp.
    Thank you very much.
    all the best.
    Yours
    Rajesh
    <title>Database Test</title>
    <font face="verdana" size=2 color="blue">
    <%@page import="java.sql.*"%>
    <%
         Connection con=null;
         Statement st=null;
         try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/emp.mdb","","");
              st=con.createStatement();
              out.println("Connected To Database ");
              out.println("<BR><BR>");
              DatabaseMetaData md = con.getMetaData();
              out.println("Driver Name " + md.getDriverName());
              out.println("<BR><BR>");
              out.println("Driver Version " + md.getDriverVersion());
              out.println("<BR><BR>");
              out.println("Database URL is " + md.getURL());
              out.println("<BR><BR>");
              out.println("Database UserName is " + md.getUserName());
              out.println("<BR><BR>");
              out.println("Connection Name " + md.getConnection());
              out.println("<BR><BR>");
              out.println("Database Name " + md.getDatabaseProductName());
              out.println("<BR><BR>");
              out.println("Database Version " + md.getDatabaseProductVersion());
              out.println("<BR><BR>");
              out.println("Database ReadOnly Type " + md.isReadOnly());
              out.println("<BR><BR>");
              out.println("MaxColumnNameLength " + md.getMaxColumnNameLength());
              out.println("<BR><BR>");
              out.println("MaxConnections " + md.getMaxConnections());
              out.println("<BR><BR>");
              out.println("");
    catch(Exception e)
         out.println(e);
         finally
              try {
                   if(st != null) {
                        st.close();
                        st = null;
                   if(con != null) {
                        con.close();
                        con = null;
              } catch (SQLException e) {}
    %>

  • Jsp and database connection using bean

    * I want create a bean to handle database connectivity.The
              <jsp:usebean> tag uses
              no argument constructor ..so I cannot pass the userid and password to
              the constructor.
              So how can I create a database connection when the user_id and password
              will be a part of parameter ?
              * Now I'm opening database connection in the jsp scriplets. Everytime I
              refresh the
              jsp page a new connection is created ? Is it not going to choke the
              database ? I cannot use connection pool because every user logs in with
              different userid.
              Thanks
              

    You can pass your arguments in this way:
              <jsp:usebean id="myBean" scope="page"/>
              <jsp:setProperty name="myBean" property="userId", value=<%= user_id%>/>
              <jsp:setProperty name="myBean" property="password", value=<%=
              user_password%>/>
              of course, in your bean class, you should create two setter methods,
              setUserId and setPassword.
              Hopefully, this will help you.
              sonia WEN
              Chiranjib Misra wrote:
              > * I want create a bean to handle database connectivity.The
              > <jsp:usebean> tag uses
              > no argument constructor ..so I cannot pass the userid and password to
              > the constructor.
              > So how can I create a database connection when the user_id and password
              > will be a part of parameter ?
              >
              > * Now I'm opening database connection in the jsp scriplets. Everytime I
              > refresh the
              > jsp page a new connection is created ? Is it not going to choke the
              > database ? I cannot use connection pool because every user logs in with
              > different userid.
              >
              > Thanks
              

  • JDeveloper10g - JSP and Database connectivity sample please

    Please someone send me a sample JSP page develped in JDeveloper10g.<br> It should create a connection (like <database:dbOpen connId="conn1" user="scott" password="tiger" dataSourcee=??> )<br>
    Is dataSource="jdbc:oracle:thin:@121.100.110.7:1521:ORCL" allowed.<br>

    You can use this tutorial:
    http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25320/querdata.htm#sthref445
    However if you are looking for an easier way of doing these type of applications try one of the ADF tutorials.

  • 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

  • Switching between Design and JSP tabs add code?

    I am new to SJSC and I am taking the time to go through all of the little odds & ends of the IDE.
    I was looking at:
    http://blogs.sun.com/roller/page/tor?entry=computing_html_on_the_fly
    And I decided to try this.
    When I add the following in the JSP tab:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>Save.
    Then click on the Design tab, then go back to the JSP tab, I now have:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>
    <h:outputText binding="#{Page1.outputText1}" id="outputText1"/>It's late here, but this doesn't make any sense, why would switching between Design and JSP tabs add code?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Girish: I followed these steps:
    1.) Downloaded:
    Sun Java Studio Creator 2, Multilanguage creator-2-windows-ml.exe 254.23 MB
    2.) When I started the install, I received the message:
    Welcome to Sun Java(TM) Studio Creator 2! You are installing: Sun Java Studio Creator 2 development environment Sun Java System Application Server Platform Edition 8.1 2005Q1 Update Release 2 Bundled database
    3.) Installed version:
    Product Version: Java Studio Creator 2 (Build 060120)
    IDE Versioning: IDE/1 spec=5.9.1.1 impl=060120
    Also, Under, the Palette window: Standard component list, there is a component labeled Output Text.
    When placed on a jsp, the following code is produced:
    <h:outputText binding="#{Page1.outputText1}" id="outputText1" style="position: absolute; left: 24px; top: 48px"/>Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Hi guys Pls tell me a way to connect db4 database with jsp and which driver

    hi guys
    Pls tell me a way to connect db4 database with jsp and
    also tell me which driver i have to use
    also tell me how to connect with excel sheets

    take a look at the follwing links. There, you'll find all what you need :
    DB4:
    http://www.oracle.com/database/berkeley-db/je/index.html
    http://www.oracle.com/technology/products/berkeley-db/je/index.html
    http://www.oracle.com/database/berkeley-db/db/index.html
    http://www.oracle.com/database/docs/berkeley-db-je-datasheet.pdf
    Excel:
    http://64.18.163.122/rgagnon/javadetails/java-0516.html
    Hope That Helps

  • MySql database and php code on different servers

    I created a table on a MySql database on server A. Now I'm
    trying to create
    a page to display the contents of the table. I know that the
    html code ( and
    php) is on a different server (server B). I managed to create
    a database
    connection however when I try this connection I cannot see
    the table I
    created. When I click on the Connection name I get the Stored
    Procedures,
    Tables and View list. I click on the Tables and although I
    get a connection
    to the server A, no table is displayed.
    Am I trying to do something silly here?
    any help will be appreciated.
    Twanny

    > Am I trying to do something silly here?
    I do it this way all the time. My testing server is local to
    my development
    LAN, but the MySQL server and database is remote (on the
    remote site). To
    make this work, you would have to make sure that the remote
    server permits
    an external connection. If it does, you should be golden.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Twanny" <[email protected]> wrote in message
    news:gabbu1$ngv$[email protected]..
    >I created a table on a MySql database on server A. Now
    I'm trying to create
    >a page to display the contents of the table. I know that
    the html code (
    >and php) is on a different server (server B). I managed
    to create a
    >database connection however when I try this connection I
    cannot see the
    >table I created. When I click on the Connection name I
    get the Stored
    >Procedures, Tables and View list. I click on the Tables
    and although I get
    >a connection to the server A, no table is displayed.
    >
    > Am I trying to do something silly here?
    >
    > any help will be appreciated.
    >
    >
    >
    >
    > --
    > Twanny
    >

  • Jsp and Code Behind

    Is it possible to create a Jsp Page the Same way that an aspx (asp.net) Page is created.
    With your basic design I.E. your html and controls in one file and then your class that extneds System.Web.UI.Page which is in you code behind file ??
    if so Are there examples of this ??

    Jsf is somewhat comparable to the asp.net controls yet I was asking if there is a way to do codebehind like asp.net pages.
    the reason for this :;
    I am converting from asp.net to jsp and want to move with the least pain.
    thanks in advance

  • JSP and HTTP return code

    I am new at developing jsp, and I am looking for a way to send an HTTP return code under a specific condition.
    for ex :
    if(data==ok)
    HTPP_return_code = 200;
    else
    HTPP_return_code = 500;
    Is it possible ?

    Within your JSP you can use the sendError method on the response object.
    e.g.
    if (data == ok) {
       response.sendError(HttpServletResponse.SC_OK);
    } else {
       response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } See http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html
    for possible HTTP return code constants.

Maybe you are looking for

  • Changing Field Labels of module pool screen dynamically

    Hi All, Can anybody tell me how to change field label of text field in dialog screen dynamically. The Screen/Transaction is standard one. I have created a Enhancement point for this change in one of PBO module's subroutine for this screen. This Field

  • QuickTime Files Out of Date

    Any time I start itunes,use the Apple site or try to use QuickTime, I get a pop up stating "Some of your Quick Time software is out of date. You can fix this by updating to the latest version (then choices of: 'Cancel', 'Do it now')". If I select 'Do

  • Outlook error when clicking on a link -- can't get to Firefox

    This used to work, now it doesn't -- i reinstalled Windows , Firefox, Office, etc. Using FF 4. When i click on a link in an Outlook email, i get a message saying "an error ocurred in sending the command to the application." How do i fix this?

  • Mail encoding question

    Whenever i receive an email with non-UTF8 encoding, the content will look like this: http://dl.dropbox.com/u/4501501/mail_content.jpg However if i view the content in the inbox mail listing, the content seems look just fine: http://dl.dropbox.com/u/4

  • Time_out dump when creating function group

    Creating a function group via SE80 in BI system generates a dump when trying to create a transport request as local object. Below is the error in the dump: Termination occurred in the ABAP program "SAPMS38L" - in   "ED_GENERATE_MAIN_PROGRAM". The mai