Apache Tomcat ROOT Directory: This is the directory that we must copy our Jsp projects.
C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.11\webapps\ROOT\JspOrnekleri
<%--------KullaniciGirisi.jsp----------%>
<html>
<body>
<%
out.println("Session ID: "+session.getId());
%>
<form method="post" action="KullaniciGirisi.jsp">
<table>
<tr>
<td>Ad:</td>
<td><input type="text" name="txtAd"/></td>
</tr>
<tr>
<td>Sifre:</td>
<td><input type="text" name="txtSifre"/></td>
</tr>
<tr>
<td><input type="submit" name="btnGonder" value="Gonder"/></td>
</tr>
</table>
</form>
<%
String ad=request.getParameter("txtAd");
String sifre=request.getParameter("txtSifre");
if(ad!=null&&sifre!=null)
{
if(ad.equals("Nurhak")&&sifre.equals("1234"))
{
session.putValue("kullaniciAdi", ad);
response.sendRedirect("SifreDogru.jsp");
}else
{
out.println("Kullanici adi veya sifre hatali");
}
}
%>
</body>
</html>
<%--------SifreDogru.jsp----------%>
<%
out.println("Kullanici adi: "+session.getValue("kullaniciAdi"));
out.println("<br>Session ID: "+session.getId());
%>
C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.11\webapps\ROOT\JspOrnekleri
<%--------KullaniciGirisi.jsp----------%>
<html>
<body>
<%
out.println("Session ID: "+session.getId());
%>
<form method="post" action="KullaniciGirisi.jsp">
<table>
<tr>
<td>Ad:</td>
<td><input type="text" name="txtAd"/></td>
</tr>
<tr>
<td>Sifre:</td>
<td><input type="text" name="txtSifre"/></td>
</tr>
<tr>
<td><input type="submit" name="btnGonder" value="Gonder"/></td>
</tr>
</table>
</form>
<%
String ad=request.getParameter("txtAd");
String sifre=request.getParameter("txtSifre");
if(ad!=null&&sifre!=null)
{
if(ad.equals("Nurhak")&&sifre.equals("1234"))
{
session.putValue("kullaniciAdi", ad);
response.sendRedirect("SifreDogru.jsp");
}else
{
out.println("Kullanici adi veya sifre hatali");
}
}
%>
</body>
</html>
<%--------SifreDogru.jsp----------%>
<%
out.println("Kullanici adi: "+session.getValue("kullaniciAdi"));
out.println("<br>Session ID: "+session.getId());
%>
Comments
Post a Comment