JSP Request Object Instance Tutorial

Source: Internet
Author: User

When we use the request object to get the data submitted by the form, this is a bit like the request Fetch data method in the ASP.


The value of the recycle is determined in the form field
The primary use of objects is the requirement that the value user provide a form submission. For example, this HTML page a.jsp:

<% 
    String bUrl = Response.encodeurl ("b.jsp");
%>

<%--Presentation--%>

<form method= "POST" action= "<%= bUrl%>" >
What is your Favourite kind of eggs?
<input type= "text" name= "FAVEGSS" size= ">
<br> <input type="
submit "value=" Submit ">
<input type= "reset" value= "reset" >
</form>
 <% String aurl = Response.encodeurl ("a.jsp");%> <% String Faveggs = Request.getparameter ("Eggs") 
    ;
if (Faveggs!= null) && (Faveggs.trim (). Length () = 0)) Faveggs = null; %> <%--Presentation--%> <% if (Faveggs = null) {%> No eggs supplied! <a href= "<%= aurl%>" &G T 
Try again</a> <%} else if (Faveggs.equals ("green")) {%> Of course-we have <%= Faveggs%> eggs!
It ' s one of our favourites too. <%} else {%> We do not have <%= Faveggs%>. Eggs} <%; 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.