I am looking for a quick and dirty way to allow a user to enter something in a text field, click a button, and have some results be displayed based on what is entered. How do I accomplish this with scriptlets in a jsp? Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t make scriptlets (java code snippets in
<% %>) execute in any other moment than the moment when the server is preparing the jsp to be rendered.In case you want to get the results server-side, you could, for instance:
actionattribute:<form action="myServlet"><input type='submit'>button in the form.myServletservlet, retrieve the textfield’s value (request.getParameter()) and perform the search. Make a request to another/the same jsp and put the results in a request attribute<% request.getAttribute(); %>UDPATE : Take into account that scriptlets are considered poor practice, use JSTL tags and Unified Expression Language instead.