Arpit Motwani
Arpit Motwani

Reputation: 13

No need to restart the server after making changes in html or javascript. Why?

We don't need to restart the server after making changes in HTML or JAVASCRIPT. But we need to restart it after making changes in Servlet or any server side code. Why?

Upvotes: 1

Views: 6265

Answers (4)

V. BRICE
V. BRICE

Reputation: 13

It's not about server-side or client-side, but about the way your server serves your application. You have used the word 'Servlets' so I assume that you are writing in JavaEE.

When your Catalina server launches the application it will load the entire app into the JVM executing the entire server. It does not track file modifications on the disk. If you want Catalina to do that you can checkout this. Why are my JSP changes are not reflected without restarting Tomcat?

Where I disagree the others answers it's about the simplification :

It's not because It's server-side code that you have to reload your server. You could find a variety of languages which tracks files modifications such as PHP for example or even your dear JavaEE as you can read it at the above link.

You can note also that It's not because HTML, CSS and JS are executed client-side you don't need to reload your server. It's because your server configuration read the files on the disk each time they are requested by a client. If you had any cache system you would need to flush it before to see your modified files downloaded to client.

Upvotes: 1

Daniel
Daniel

Reputation: 631

Because HTML and JS executes on client side - in users browser. Instead of server side code. But it's not right proposal to restart server on code change, because server side code execute on each user external request by server.

You code can make some kind of caching to not execute code before some special server side event happens.

Upvotes: 0

user1258361
user1258361

Reputation: 1133

Server code is just a program. When you run a program, its content is loaded into RAM and run. If you update the program, the version on disk is updated, however the old version remains in RAM. You have to close the old version of the server program and run the new one.

HTML and Javascript are rendered on clients. These usually aren't loaded into the server's RAM (except for caching purposes). HTML/JS aren't even part of the server code (although JS can interact with a server, AJAX is a prominent example)

Upvotes: 0

trishulpani
trishulpani

Reputation: 754

HTML and JS are interpreted by your browser runtime and hence the changes are reflected immediately on browser refresh. Servlets and server side code usually require compilation and hence requires a server restart. A server restart forces the reload of changed classes. That's why JRebel is interesting (it enables server-side class reloads without server restarts). Hope this helps!

Upvotes: 2

Related Questions