0

I am using JSP and Servlet to build a simple app, how can I encrypt form data before submit? here is my JSP:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
        <h1>Enter the text</h1>
        <%
            String txt=" ";
            txt = (String) request.getAttribute("lower");
           
        %>
        <form action="ser1">
           
            <textarea name="txt" rows="3" cols="20"  placeholder="Enter here"></textarea>
            <textarea  rows="3" cols="20" > <%=txt%></textarea>
           
            <input type="submit">
        </form>

    </body>
</html>

And here is processRequest method in the Servlet:

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       String txt = request.getParameter("txt");
       request.setAttribute("lower", txt.toLowerCase()); 
       this.getServletContext().getRequestDispatcher("/1.jsp").forward(request, response);
       
    }
0

1 Answer 1

2

Encrypted over the network

If you use a secure https web connection via TLS, the data is already encrypted over the network. This can be accomplished via Web server configuration settings, with no need to change your web app coding.

Web browsers and web servers have already been built to the latest encryption technologies. This includes Java-based servers such as Apache Tomcat & TomEE, Eclipse Jetty, Glassfish & Payara, WildFly & JBoss, OpenLiberty & WebSphere, and so on.

No need for you to reinvent that wheel.

Encrypted storage

If you want the data stored in an encrypted format, that encryption should be performed on the backed by the server software, not the web client.

Get the data from the client to the server via https/TLS, then encrypt on the backend.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.