Wednesday, 15 September 2010

java - Null result being displayed using jsp -


I am new to the concepts of dynamic web project. I have made the following two JSP and a Java class experiment. Please give me the following code

user.java

  package com; Public Class User {Name of Private String; Private Ent ID; Public int getId () {return ID; } Public Zero Set ID (Ent ID) {ID = ID; } Public string getName () {return name; } Public Zero Setname (string name) {this.name = name; }}   

index.jsp

 % @page language = "java" contentType = "text / html ; Charset = ISO-885 9-1 "Page encoding =" ISO-885 9-1 "%> & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transcription // N" "http://www.w3.org/TR/html4/loose.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-885 9-1" & gt; & Lt; Title & gt; Insert title here & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form action = "first.jsp" & gt; Name & lt; Input type = "article" name = "name" /> Id & lt; Input type = "text" name = "id" /> & Lt; Input type = "submit" value = "SUBMIT" /> & Lt; Jsp: useBean id = "user" class = "com.User" /> & Lt; Jsp: setProperty name = "user" property = "*" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

And then the first. Jsp

  & lt;% @ page language = "java" contentType = "text / html; charset = ISO-8859-1" page encoding = "ISO-8859-1"%> ; & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transcription // N" "http://www.w3.org/TR/html4/loose.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-885 9-1" & gt; & Lt; Title & gt; Hello & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Jsp: useBean id = "user" class = "com.User" /> User is: & lt;% = user.getName ()%> & Lt; Br> ID is: & lt;% = user.getId ()%> & Lt; Br> & Lt; / Body & gt; & Lt; / Html & gt;   

But it is showing me nonsensical for both values. I know its very easy program. But I'm not getting the concept correctly

thanks

move < / P>

  & lt; Jsp: useBean id = "user" class = "com.User" /> & Lt; Jsp: setProperty name = "user" property = "*" /> Request parameters from  first.jsp    

index.jsp are submitted to First.jsp and not index.jsp < / P>

  & lt; Jsp: setProperty name = "user" property = "*" />   

The user populates with the criteria from the request parameters with those criteria. The form is presented to First.JSP, which receives the request parameter.

No comments:

Post a Comment