Mehmet Ethem SULAN :: JSP(Java Server Pages) :: How to input and output parameters from JSP to Java Beans



<%@page contentType="text/html" pageEncoding="UTF-8"%>
JSP Page 
<form action="UyeBilg.jsp" method="POST">

<%-- Buradaki name,parola1,parola2 yani JavaBeanimizdeki
degiskenelrle ayni olmalidir.Yani isimelr ayni olamli.--%>





Email Adresi: <input type="text" name="email"/>
Parola: <input type="password" name="parola1"/>
Parola Tekrar: <input type="password" name="parola2" value="" />
<input type="submit" value="Uye Ol" />

Orj kod:


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="" %>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        JSP Page
out.println("Parolar ayni degil");
//return sistemi bu if{} icinde durduruyor.Yani asagidaki kisimlar islenmiyor.
<jsp:useBean id="a" class="" scope="request"/>
<jsp:setProperty name="a" property="email" value="${param['email']}"/>
<jsp:setProperty name="a" property="parola1" value="${param['parola1']}"/>
<jsp:setProperty name="a" property="parola2" value="${param['parola2']}"/>
            out.println("Benandeki degerler asagidaki gibidir
            <jsp:getProperty name="a" property="email"/>
            <jsp:getProperty name="a" property="parola1"/>
            <jsp:getProperty name="a" property="parola2"/>

            String email;

Javabendeki email: <input type="text" name="email"
          value="<jsp:getProperty name="a" property="email"/>"/>
Degiskene atilan bean degeri :
            Uye uyeNesnem=new Uye();
//beanimizda baska metod tanimlayabiliriz.Fakat
// beandaki degerleri direkt alamaz.gene null olur
//Baska bean icin metod tanimlanabilir javabean icinde.
Beanimize nesne uzwerinden elemanlarin
" +
" degerlerini alamiyoruz. Email degeri null olur :"+uyeNesnem.getEmail());
Benadeki metod :

orj kod:


//JavaBean degiskenelre sadece get ve set metodlariyle erisilir
//Bu metod ve degiskenelr static olamaz.
//Buradaki bilgiler jsp sayfalari arasinda bilgi tasinmayi saglar
public class Uye {
    private String email=null;
    private String parola1=null;
    private String parola2=null;
    public String getEmail() {
        return email;
    public void setEmail(String email) { = email;
    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;
//JavaBeanimizde baska metod tanimlama
    public int baskaMetod(){
        return 34+17;
    }  }

Orj kod:


There is one comment for this post.

  1. Antony on Nisan 3, 2012 12:39 pm

    I have to express some tanhks to this writer for bailing me out of such a circumstance. Right after browsing through the world wide web and getting strategies that were not pleasant, I believed my entire life was gone. Existing minus the answers to the issues you’ve solved as a result of this post is a crucial case, as well as the ones which might have negatively affected my entire career if I had not come across your web blog. Your main training and kindness in playing with all the stuff was very helpful. I’m not sure what I would have done if I hadn’t come upon such a point like this. It’s possible to now look ahead to my future. Thank you so much for this professional and results-oriented help. I won’t think twice to suggest your site to anybody who should have guide on this subject.

Write a Comment

Let me know what you think?