I'm in a dilemma about how to add the above three technologies. I am still a student so please Bare together because I try to explain my problem.
For an assignment, I have to create a simple form which uses JSP for visualization with the model and being a controller servlets, communication requires the use of Javabins.
I have created a JSP power form to accept a username and password that the user should be able to post. See the message in the forum I have used the following code to read the JSP text box:
& lt;% @ page import = "forum.beans. *"% & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Login - Message Board & lt; / Title & gt; & Lt;% string uname = request.getParameter ("uname"); String pass = request.getParameter ("pass"); & Gt%; & Lt; / Head & gt; & Lt; Body bgcolor = "lightstyleblue" & gt; & Lt; Font face = "Calibri, Century Gothic, Times New Roman" & gt; & Lt; Table border = "0" align = "center" & gt; & Lt; Form method = "post" action = "servlet \ controller" & gt; & Lt; TR & gt; & Lt; Td> Username: * & lt; / Td> & Lt; Td> & Lt; Input Name = "Username" value = "& lt;% = uname%>" Type = "text" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> Password: * & lt; / Td> & Lt; Td> & Lt; Input name = "password" value = "& lt;% = pass%>" Type = "password" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td align = "center" & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "login" /> gt; & Lt; / Td> & Lt; Td align = "center" & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "reset" value = "clear" /> & Lt; / Td> & Lt; / TR & gt; & Lt; / Form & gt; & Lt; / Table & gt; & Lt; / Font & gt; & Lt; / Body & gt; & Lt; / Html & gt;
My questions are,
I used the
<%> request.getParameter (" Uesername ");%>
The other thing is how can these values be transferred to JSP tags ??
Thank you very much or your time people
& lt;% request.getParameter ("Usense");% & gt;
You should do this in the doPost ()
method of the servlet that is listening on the form URL of the form. It should be noted that in the case of a good JSP / circlet model / visual / controller design, JSP should include the No scriptlet line. Keep this in mind. See also for many signals.
The other thing is how can these values be transferred to JSP tags?
You can call it $ {param}}
in EL, basically it's a map & lt; String, string & gt;
where the name of the parameter is key.
& lt; Input name = "username" vaule = "$ {param} .username}" & gt;
It should be mentioned that this is sensitive to XSS attacks. If you want to solve this, you can earn extra points;)
Another unrelated comment: HTML & lt; Font & gt; The
tag is not deprecated since 1998. Make sure that you have learned about it, but those sources are out of date. You can use CSS to style the HTML document.
Comments
Post a Comment