Google+ Followers


Get Updates Via Email

Enter your email address:

Delivered by FeedBurner

Sunday, 26 January 2014

How to use Multi-Select Dropdown List in html select input using Jquery in JSP page with limited selections ?

Below Code Snippet shows Selecting Multiple Values

 Below code index.jsp page with jquery javascript, css, Ui, codes are imported

Output Page:

Jsp / Java Password Encrypt and Decrypt Example

From Previous post Now in this post I will use Encryption/ Decryption mechanism on password input password field using AES algorithm,

I am just adding class and it has two methods;

1. Encrypt Method encrypt(String strToEncrypt) to encrypt the user given password to cipher text
2. Decrypt Method decrypt(String strToDecrypt) to decrypt the ciper text back to original password content.

Below code shows class file

From the Java class file you can encrypt the password to cipher text and back to original password using decrypt the cipher text done by this below code snippet.


JSP and Servlet Form Submission without page refresh show results on the same page using Jquery AJAX

Code Snippet

HTML Form 

<form id='ajaxform' name='ajaxform' action='ajaxformexample' method='post'>
 First Name: <input type='text' id='firstname' name='firstname' size='30' required/><br/>
 Last Name: <input type='text' id='lastname' name='lastname' size='30'required/><br/>
 Email:  <input type='email' id='emailid' name='emailid' size='30'required/><br/>
 Password:  <input type='password' id='pwd' name='pwd' size='30'required/><br/>
 <input type='Submit'/> 
 <div id='content'>

the above HTML Form uses post method and url servlet redirect to "ajaxformexample"

Javascript Code

 var form = $('#ajaxform'); // id of form tag
 form.submit(function () {

 type: form.attr('method'),  //post method
 url: form.attr('action'), //ajaxformexample url
 data: form.serialize(), // serialize input data values
 success: function (data) {
 var result=data;
 $('#content').html(result); //showing result


 return false; // not refreshing page


the above javascript code uses Ajax jquery concept and parameters type, url,data, and finally success function to show result from specified action SERVLET performed results back to same page and in the below code snippet Servlet uses doPost method to get values in the input fields;

public void doPost(HttpServletRequest req, HttpServletResponse resp)
   throws IOException {
  PrintWriter out=resp.getWriter();
  String fname= req.getParameter("firstname");
  String lname= req.getParameter("lastname");
  String email= req.getParameter("emailid");
  String password= req.getParameter("pwd");
  out.println("<br/><br/>First Name = "+fname+"<br/><br/>Last Name = "+lname+"<br/><br/>Email = "+email+"<br/><br/>Password = "+password);

index.jsp Page

servlet Java