Archive for the ‘ Struts Web Application Framework ’ Category

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%-- struts-bean.tld tagini kullanmamizi sagliyor.Beanlerle ilgili bir cok komutu iceriri
ornekte  gibi--%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
JSP Page

Gecersiz Deger Gridiniz:


Bos Ad Olamaz: <bean:write name="BilgiGirActionForm"
            property="kulAd" filter="false"/>

 Email ethemsulan@gmail.com seklinde olmali:
<bean:write name="BilgiGirActionForm"
   property="kulEmail" filter="false"/>

Parola1 parola2 ile ayni olmali:
<bean:write name="BilgiGirActionForm"
   property="parola1" filter="false"/>

Parola1 parola2 ile ayni olmali
<bean:write name="BilgiGirActionForm"
    property="parola2" filter="false"/>

    

Orj Kod:http://www.ethemsulan.pastebin.com/f18bc723

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%--BilgiGirActionForm beandeki propertry leri yazar. filter=false de
html nin strusa erisimi saglariz.Aksi halde html karekteri filtrelenmis olur--%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
JSP Page

Tebrikelr basariliyle kayit gerceklesti


kullanici Adi:<bean:write name="BilgiGirActionForm"
            property="kulAd" filter="false"/>

Email: <bean:write name="BilgiGirActionForm"
            property="kulEmail" filter="false"/>

Parola: <bean:write name="BilgiGirActionForm"
            property="parola1" filter="false"/>

    

Orj Kod:http://www.ethemsulan.pastebin.com/f76f55284

gene

struts-bean.tld yuklu ve postgresql driverida libraries sağ tıklayıp yüklemiş olmalı.Projeden index.jsp dosyasını xml den değiştirdim BilgiGir.jsp      Sql:

DROP TABLE "kisi";
CREATE TABLE "public"."kisi" (
"ad" varchar DEFAULT NULL,
"email" varchar DEFAULT NULL NOT NULL,
"parola" varchar DEFAULT NULL,
CONSTRAINT "kisi
_pkey" PRIMARY KEY ("email")
)
WITH (OIDS=FALSE)
;

ALTER TABLE "public"."kisi" OWNER TO "postgres";;

-- ----------------------------
-- Records of kisi
-- ----------------------------
INSERT INTO "kisi" VALUES ('ethemsulan', 'ethemsulan@gmail.com', 'ethem');
<%@page contentType="text/html" pageEncoding="UTF-8"%>
   

Bu text name isimleriyle BilgiGirActionForm beanimizdaki isimler aynı olmalı.


<form action="BilgiGir.do" method="POST">


 



 




 
Kullanici Adi:E-mail: Parola:Parola Tekrari:
<input type="text" name="kulAd" value="" /> <input type="text" name="kulEmail" value="" /> <input type="password" name="parola1" value="" /> <input type="password" name="parola2" value="" />
<input type="submit" value="kayit Ol" <input type="reset" value="Iptal">

Odj Kod:http://www.ethemsulan.pastebin.com/f480bc0e7

package www.ethemsulan.com;
public class BilgiGirActionForm extends
        org.apache.struts.action.ActionForm {
    private String kulAd;
    private String kulEmail;
    private String parola1;
    private String parola2;
public BilgiGirActionForm() {super();}
public String getKulAd() {return kulAd;}
 public void setKulAd(String kulAd) {this.kulAd = kulAd;}
public String getKulEmail() {return kulEmail;}
public void setKulEmail(String kulEmail) {
    this.kulEmail = kulEmail;
    }
public String getParola1() {return parola1;}
public void setParola1(String parola1) {
    this.parola1 = parola1;
    }
public String getParola2() { return parola2;}
    public void setParola2(String parola2) {
        this.parola2 = parola2;
    }  }

Orj Kod:http://www.ethemsulan.pastebin.com/f5eb2cd1a

package www.ethemsulan.com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class KayitEtAction extends
        org.apache.struts.action.Action {
 public ActionForward execute(ActionMapping mapping,
    ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
//beanimizdeki degerleri aliyor.psotgresqle kaydediyor uygunsa.
BilgiGirActionForm benaimiz=(BilgiGirActionForm)form;
String kAd=benaimiz.getKulAd();
String kEm=benaimiz.getKulEmail();
String kPa1=benaimiz.getParola1();
 String kPa2=benaimiz.getParola2();
Class.forName("org.postgresql.Driver");
Connection baglanti=DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/postgres", "postgres", "ethemsulan");
Statement ifade=baglanti.createStatement();
//yanlis veri girilince kayit gerceklesmiyor ve BicimOner sayfasina gonderiliyor yanlis stringi sayesinde
if(!(kPa1.trim().equals(kPa2.trim())) | "".equals(kEm) |
  (kEm.indexOf("@")==-1) | "".equals(kAd)| "".equals(kPa1)){
 return mapping.findForward("yanlis");
        }
//dogru veri girilmise return mapping.findForward("basarili"); basarili stringine gore
//struts-config.xml deki forward ile Gerceklesti.jsp sayfaina yonlendiriyor.
//o sayfadanda bu beanimizdeki degerleri alip ekrana yaziyor
ifade.executeUpdate("insert into kisi(ad,email,parola)" +
        " values('"+kAd+"','"+kEm+"','"+kPa1+"') ");
return mapping.findForward("basarili");
    } }

Orj Kod:http://www.ethemsulan.pastebin.com/f48f7c
384

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">

//beanler burada tanimlanir

<form-bean name="BilgiGirActionForm"
  type="www.ethemsulan.com.BilgiGirActionForm"/>
    
    
    
    
    
<forward name="welcome"  path="/Welcome.do"/>
    
//Dikkat input bilgi nerden gelecek.name bilgiyi kim alacak
//type ise bilgiyi alan benaimizden kim alip isletecek
<action input="/BilgiGir.jsp" name="BilgiGirActionForm"
  path="/BilgiGir" scope="session"
type="www.ethemsulan.com.KayitEtAction">
//KayitEtActiondan yanlis stringi gelirse BicimOner.jsp yi calistir
//basarili gelirse Gerceklesti.jsp yi calistir(yonlendir)
<forward name="yanlis" path="/BicimOner.jsp"/>
<forward name="basarili" path="/Gerceklesti.jsp"/>
    
//action burada bitmis dikkat edin.forward tagin icinde tanimlanmis

 <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="com/myapp/struts/ApplicationResource"/>    
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
 <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />      
<set-property property="moduleAware" value="true" />

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
    property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
 

Orj Kodlar:http://www.ethemsulan.pastebin.com/f16eb252d

http://www.ethemsulan.pastebin.com/f18bc723

http://www.ethemsulan.pastebin.com/f480bc0e7

http://www.ethemsulan.pastebin.com/f76f55284

http://www.ethemsulan.pastebin.com/f5eb2cd1a

http://www.ethemsulan.pastebin.com/f48f7c384