like this :
jsp in :
<%
out.println ("");
%>
servlet in :
String name = request.getParameter ("userName");
get the value of less than userName .
because I have some special judge, so the output of some form form in java code snippet , how to receive their values ?
------ Solution ---------------------------------------- ----
when the form is submitted , the background can be based on input name = "userName" value , do not need to write the script. You certainly get that way writing can not.
------ For reference only -------------------------------------- -
how to obtain it . .
------ For reference only -------------------------------------- -
jsp code is our teacher gave , servlet functionality did not realize that this issue get me one night. .
------ For reference only -------------------------------------- -
want to achieve what effect , to write java code in jsp dom is generated norms
really wanted to write , with such
<%
out.println ("");
%>
then click on the input button is where the form can be submitted to the corresponding servlet in
------ For reference only ---------------- -----------------------
not see your userName field has a value
------ For reference only ---------------------------------------
did not see your domain has a value of userName
I mean, his page has when the form is submitted to the servlet , servlet can get the value of userName attribute name based on input text box
request.getParameter ("userName");
------ For reference only ------------------------ ---------------
tried, looks or not.
<%
for (customer cus: clist) {
out.println ("
if (! cus.getCustomerID (). equals (session.getAttribute ("editid" ;) ) ) {
out.println ("
out.println ("
out.println ("
out.println ("
out.println (" Edit
} else {
out.println (" "); ;
out.println ("
out.println ("
out.println ("
out.println ("
out.println (" Cancel
}
out.println ("
}
%>
just want to achieve edit, then OK, the servlet can not receive text into the cname and cphone
------ For reference only ------------- --------------------------
did not see the value of your domain has userName
I mean, his page has when the form is submitted to the servlet , servlet can get the value of userName attribute name based on input text box
request.getParameter ("userName");
yes ah, the problem is the code you write is an empty string , ah, the resulting string is empty , is it null? If you submit null description form field is not userName field
------ For reference only --------------------------------------- < br>
tried, looks or not.
<%
for (customer cus: clist) {
out.println ("
if (! cus.getCustomerID (). equals (session.getAttribute ("editid" ;) ) ) {
out.println ("
out.println ("
out.println ("
out.println ("
out.println (" Edit
} else {
out.println (" "); ;
out.println ("
out.println ("
out.println ("
out.println ("
out.println (" Cancel
}
out.println ("
}
%>
just want to achieve edit, then OK, the servlet can not receive text into the cname and cphone
out.println ("
------ For reference only ---- -----------------------------------
how to obtain it . .
I wrote a simple example
<%
String path = request.getContextPath ();
String basePath = request.getScheme () + ":/ /" + request.getServerName () + ":" + request.getServerPort () + path + "/" ;
%>
The code above is jsp page has the web project , the project is to get the script path , do not need to write .