• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is their any wrong in my JSP structure?

 
manohar gunturu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I developed a webapp using JSP but i didn't used JSTL tags much and i didn't used beens also.
Everything i written like
<%@//some pakages%>
<%
//database connection

//if and for loops

%>
<html>

<%

//for loops
%>
</html>
is their any problem writing whole jsp code in this manner


 
manohar gunturu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry to mention even my jsp page contains javascript also
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it is considered bad design to keep any Java code in a JSP. That's what servlets and backing beans are for.

There's nothing wrong with keeping JavaScript code in a JSP, but if it's a lot you should consider moving that into its own file that the HTML can then load.
 
manohar gunturu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why it is considered as bad design is their any security restrictions..
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's got nothing to do with security, it's just bad design. These days (for the last 10 years, actually), separation of concerns has taken hold in software design. For web apps, that means using MVC, amongst others. See https://www.coderanch.com/how-to/java/Model1Model2MVC and http://www.javaranch.com/journal/200603/Journal200603.jsp#a5 for more information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!