[Logo]
Forums Register Login
Converting JSP to servlet
following is the code


how can we write following line in servlet
Why would you want to to do that?

Granted, putting JDBC code into a JSP is a bad practice, but so it emitting HTML from a servlet.

if you are going to refactor this code, you should move the JDBC code into the Model layer, and use the servlet to fetch the data from the model as a Java collection, not a result set. This collection will be sent to the JSP page for creating the view.

For more information of properly structuring web apps please read this article.
 

Megha Singhal wrote:following is the code


how can we write following line in servlet


i convert it like following, am i wrong somewhere.
hi,

As long as above servlet code is working well there is no issue. But it might suffer from performance related issue if number of records are more in ResultSet. Use StringBuffer object in loop to create entire output string and then pass the same to out.println() function.
 

bhavesh gawade wrote:hi,

As long as above servlet code is working well there is no issue. But it might suffer from performance related issue if number of records are more in ResultSet. Use StringBuffer object in loop to create entire output string and then pass the same to out.println() function.



Thanks for your help, my problem has solved.
Oh the stink of it! Smell my tiny ad!
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 1353 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 20, 2018 06:39:15.