Usually, servlets and JSPs are used in conjunction; using just one is just as bad as using just the other. Can you tell us what the circumstances are?
Joined: Feb 20, 2012
The servlet that I am using in my application returns me HTML which shows calender structure. Now I have to replace that servlet with jsp that means I have to add the java code of servlet (returns calender in HTML fromat) into new jsp.
Joined: Sep 21, 2011
Java code in JSPs is very bad practice, and not necessary. You should use a servlet that contains all Java code, and which adds request attrbutes with all data that the JSP requires for display. The request is then forwarded to the JSP which proceeds to use the request attrbutes to generate the HTML.
Likewise servlet code which outputs HTML is a bad thing, which hopefully is why you've been told to change this servlet.
So you're going to have to redesign. That means you will have to look at the servlet and figure out which part is logic needed to set up data, and which part is writing that HTML. Quite likely you will find that the two parts are intermingled. Then you will have to rewrite the code so that the "logic needed to set up data" is retained in the new version of the servlet, with changes made so that the data is put into request-scoped variables rather than in local Java variables in the doGet method. And you will need to write a new JSP which writes out the desired HTML, using the scoped variables which the servlet created.
In other words, it's basically a rewrite. Think of it as hitting the original code with a big hammer, then taking the debris and putting the "servlet" bits into one pile and the "JSP bits into another pile, then making the two piles into useful code. Not necessarily an easy task.