Link to home
Start Free TrialLog in
Avatar of Doneen
Doneen

asked on

JSP & Access

Can i use access with JSP??
If so has anyone got code i can use to connect to a Access database,
read from it,display this on the web,
Also has anyone code on how to insert with JSP,
I know how to create SQL statements I basically need the the JSP code to open the link to the database,display the info etc, and to assign variables that can be used to pass to the database fields
Avatar of NetGroove
NetGroove

To move your question to the correct topic area ask for support in this topic area:
https://www.experts-exchange.com/Community_Support/

Avatar of Doneen

ASKER

all JSP code in general for form a web page would be appreciated,
an overall example of a page accessing a database,display & inserting into the database would be I feel the best possible solution for me.
I could then edit it to connect to my own database and read from it,
Drop down menus being created from field in the database would be very useful,
Thanks,
Shane.
PS-I could do with an answer to this fairly soon,so any help would be appreciated.
But you are again in wrong topic area.
This is JavaScript topic area.

To end your Odyssey look here:
http://cse-ferg41.unl.edu/docs/DevelopmentDocs/jdbcpage/jdbc.htm

Avatar of Doneen

ASKER

Can it be moved to
https://www.experts-exchange.com/Web/Web_Languages/JSP/
here so,
Thanks
Avatar of TimYates
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is the Login.jsp
<%@ include file="vw02Constantes.jsp"%>
<%@ page import="vw02.com.*"%>
<%@ page import="vw02.Vw02Login"%>
<%

      boolean paginaLogin = true;
      String error = "";
      String usuario = "";
      
      Vw02Sesion sess = null;
      
      // Check it there is a session already
      sess = new Vw02Sesion(session, true);
      
      if (sess.haySesion()) {
      %>
            <SCRIPT>
            alert("There is a session already");
            parent.location.href="start.jsp";
            </SCRIPT>
      <%
      }
      // if not Check if the user has logged in
      if (request.getParameter(ENTRAR) != null) {
            if (OK.equals(request.getParameter(ENTRAR))) {
                  paginaLogin=false;
                  usuario = request.getParameter(Vw02Constantes.LOGIN);
                  Vw02Login login = new Vw02Login(request);
                  
                  try {
                        if (login.enter()) {;
                        
                        %>
                        <SCRIPT>
                              parent.location.href="start.jsp";
                        </SCRIPT>

                        <%
                        
                        } else {
                              error = "User o Password Failed, try again";
                              paginaLogin=true;
                        }
                        
                  } catch(Exception e){
                        e.printStackTrace();
                        paginaLogin = true;
                        error = "Unexpected Error. Try Later";
                  }
            }
      }

      if (paginaLogin) {      
%>

<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript" src="/VW02/Motivacion/Programa/js/scripts.js"></SCRIPT>
<SCRIPT language="JavaScript">

function send() {
      
      frm = document.forms[0];


if (frm.<%=Vw02Constantes.LOGIN%>.value=="") {
      
            alert("Please, Enter User Name.");
            frm.<%=Vw02Constantes.LOGIN%>.focus();
            return false;

} else if(frm.<%=Vw02Constantes.CLAVE%>.value=="") {
      
            alert("Please Enter Password.");
            frm.<%=Vw02Constantes.CLAVE%>.focus();
            return false;
}

return true;

}
</SCRIPT>

</head>

<body bgcolor="#000066" text="#0066FF" leftmargin="0" topmargin="0">
<table width="100%" border="0">
  <tr>
    <td width="9%"><img src="lv55.gif" width="82" height="81"></td>
    <td width="86%">
      <h1 align="center"><font face="Arial, Helvetica, sans-serif"><font size="5">LOGIN PAGE</font></font></h1>
    </td>
    <td width="5%"><img src="VW.gif" width="82" height="81"></td>
  </tr>
</table>
<form name="frm" method="post" action="<%=LOGIN_JSP%>" onsubmit="return send()">
  <input type="hidden" name="<%=ENTRAR%>" value="<%=OK%>">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <div align="center">
    <table width="50%" border="1">
      <tr>
        <td>
          <table width="100%" border="0">
            <tr>
              <td width="17%" height="25">&nbsp;</td>
              <td width="13%" height="25">&nbsp;</td>
              <td width="28%" height="25">&nbsp;</td>
              <td width="42%" height="25">&nbsp;</td>
            </tr>
            <tr>
              <td width="17%">&nbsp;</td>
              <td width="13%">&nbsp;</td>
              <td width="28%">&nbsp;</td>
              <td width="42%">&nbsp;</td>
            </tr>
            <tr>
              <td width="17%">&nbsp;</td>
              <td width="13%">Usuario:</td>
              <td width="28%">
                <input type="text" name="<%=Vw02Constantes.LOGIN%>" value="<%=usuario%>">
              </td>
              <td width="42%">&nbsp;</td>
            </tr>
            <tr>
              <td width="17%" height="32">&nbsp;</td>
              <td width="13%" height="32">Clave:</td>
              <td width="28%" height="32">
                <input type="password" name="<%=Vw02Constantes.CLAVE%>" value="">
              </td>
              <td width="42%" height="32">
                <div align="center">
                  <input type="submit" name="bLogin1" value="Conectar">
                </div>
              </td>
            </tr>
            <tr>
              <td width="17%" height="36">&nbsp;</td>
              <td width="13%" height="36">&nbsp;</td>
              <td width="28%" height="36">&nbsp;</td>
              <td width="42%" height="36">&nbsp;</td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
</form>

<% if(!"".equals(error)) { %>
  <SCRIPT>
     alert("<%=error%>")
  </SCRIPT>
<% } %>
</body>
</html>
<% } %>
Here is the start.jsp wich only populates the Countries drop down list.
<%

Vector vPaises = null;
Vw02Paises oPais = new Vw02Paises();
vPaises = sess.getPaises();

%>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#000066" text="#FFFFFF" leftmargin="0" topmargin="0" onLoad="init();">
<div align="center"> <font face="Arial, Helvetica, sans-serif">
<select name="paises" onchange="javascript:cargalistas(this);">
<option selected>Seleccione Pais</option>
<%
if (vPaises!=null) {
      for (x=0; x<vPaises.size() ; x++) {
            oPais = (Vw02Paises)vPaises.get(x);
            %>
            <option value="<%=oPais.getCodigoPais()%>"> <%=oPais.getNombre()%> </option>
            <%
            oPais = null;            
      }
}
%>
</select>
</font>
</div>
</body>
</html>

Have Fun
Javier
Avatar of Doneen

ASKER

applekanna
Can anyone suggest where I could get a suitablle driver,for the piece of code you posted,
I have been away for awhile hence i was not working on this ,
thanks for all your help,
I am just looking to connect to the database first and will go into more detail once i get this done,
Thanks again,
any help would be greatly appreciated,
Doneen.

The jdbcodbc driver comes with the JDK you should have it

Javier

Avatar of Doneen

ASKER

I don't think I have a JDK,
I am using iplanet a netscape webserver,
And am coding it with Dreamweaver,
Any suggestion,
or does this make sense the way I am tryin to do it??
Well if you're using iPlanet then you sure have a jdk, iPlanet is java based and can not work without a jdk, anyway have you tryied downloading one from the sun page http:\\www.sun.com
besides that you should need an ODBC DNS entry to pion your access database.
Any further questions do not doubt to ask
:c)
Javier