Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3354598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:17:33+00:00 2026-05-18T02:17:33+00:00

I’m practising a bit on JSP and want to create a simple formular field.

  • 0

I’m practising a bit on JSP and want to create a simple formular field. The code below is working properly. Now i want that the last input stays in the formular fields. So when i type in a value “password” and a “name” both values should stay in the formular field no matter what the result of the if-else statement is.

For example i type in “user” and “1234” and press submit the formular fields get cleared and i don’t want that. The two values shall stay there after submitting. Sincerly i have no good idea how to solve this problem.

My suggestion would be to use application.setAttribute(“”,) and application.getAttribute(“”), but i don’t know how. I would be glad for any advise. Thank you!

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
          "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">

<head>
  <title>Practice</title>
</head>

<body>

<h2>Practice</h2>
<h3>Please enter your name and the password.</h3>
<form method="post" action="">
  <table>
<tr><td style="text-align:center">Name</td>
<td><input type="text" name="name" size="80" /></td>
</tr>
<tr><td style="text-align:center">Password</td>
<td><input type="text" name="password" size="80" /></td>
</tr>
<tr><td><input type="submit" value="Send" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
</table>
</form>

<%-- Testing name and password. --%>
<% String name = request.getParameter("name");
   String password = request.getParameter("password");
   if (name != null && name.equals("user") && password != null && password.equals("1234"))
     {
%>
       <p>Your Input is correct!</p>
<%   }

   else
     {
%>
       <p>Your input is not correct!</p>
<%   }
%>

</body>


</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:17:34+00:00Added an answer on May 18, 2026 at 2:17 am

    Just fill their value attribute with the submitted value. In normal JSP EL that would be:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    ...
    <input type="text" name="username" value="${fn:escapeXml(param.username)}" />
    <input type="password" name="password" value="${fn:escapeXml(param.password)}" />
    

    The ${param.username} does basically the same as the following ugly scriptlet <% if (request.getParameter("username") != null) { out.print(request.getParameter("username")); } %>, only in a much more clean and consice way.

    The JSTL fn:escapeXml() function is there to prevent you from XSS attacks. Otherwise users would be able to enter "><script>alert('xss');</script> as name and get it executed (of course with a more malicious javascript which sends the cookies to another server for example instead of a simple alert).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.