Bookmark Topic Watch Topic
  • New Topic

What is difference between these two <%! %> and <% %>?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi there

Although I have read this thread on SO.

But I don't get clear meaning of these two when two use which tags?


Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Both are obsolete and should not be used. Ever.

The version with the bang puts the declarations inside at class level versus inline.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have one more thing that is creating confusion what to use?

Like in PHP we write code of PHP +HTML on a single page

1)Can we do that also in JSP?(is it good or not?)

2)Most of the time what I use like in case of POST.Pass request to a servlet->Initiate Db connection in servlet->Notify user with approriate message from database.

I want to know which approach I should use for database operations?
(Calling database from JSP or
Passing parameters from JSP to servlet then servlet will call to database)

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Kishor Joshi wrote:1)Can we do that also in JSP?(is it good or not?)

No, it's not good. Scriptlets have been obsolete for 13 years for good reason. You should be writing modern JSPs with eh El (Expression Language) and JSTL (JSP Standard Tag Library).

2)Most of the time what I use like in case of POST.Pass request to a servlet->Initiate Db connection in servlet->Notify user with approriate message from database.

Bad practice. As I pointed out in your other post, DB access should be in the model, not the presentation layer (view and controller).

(Calling database from JSP or
Passing parameters from JSP to servlet then servlet will call to database)

Covered in your other post. Please do not repeat the same question in multiple posts.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!