Why is jsp used at client side? - javascript

I am working on a project on spring MVC which has the code in the client side in jsp instead of javascript and html. I would really appreciate if you could explain why this is used and not javascript and html. Can this be replaced by javascript and html without loss of functionality

JSP is executed on server side and it renders an HTML page (including embedded javascript and css). So on your browser Javascript and HTML code is executed, not the JSP code.
You can verify the same by using developer tools of your browser, you wont find any JSP code there.
And yes, all your work can be done by Javascript/HTML as well. Just that you will have to use AJAX to get the dynamic data that you need to show of your page.

Related

HTML/Javascript/Bootstrap Webpage Does Not Display Text Until I Use Inspect Element

I'm making a Tomcat and JavEE web app, but for the front end I am using a free javascript + html template. I am using a JSP with JSTL in place of html files, and including the javascript and other resources in tomcat 8.5/webapp.
However, when I call the JSP, I have this weird problem where the text that I display does not show up unless I click inspect element.
This happens on all browsers.
I think it might be some problem with the way that JSP/JavaEE works with javascript, because the template works fine when it is not used as a javaEE project.
Does anyone know common problems that cause this?

How to know HTML page needs to be rendered by JS compiler?

I am trying to crawl some websites and while I am using headless chrome browser with selenium to render some HTLM that have embedded JS, I would also like to simply use requests, for the cases where there is no need for JS code rendering.
Is there a way to know if the HTML needs to be rendered by a browser or if a simple requests.get() would give me the complete HTML content?
Any HTML code generated by tags won't be retrieved by requests.
The only way to know if a page would need to be rendered by a browser to generate the whole content is to check if its HTML code has tags.
Still, if the information you are interested on is not generated by JS, requests.get() will serve you well.

Dynamic HTML with Javascript in JavaFX Webview

I will try to ask my Question as precise as I can. At the moment I cannot post any example Code as I'm not allowed to post code of my work. In my next free time I will lookup that I will code some example to be more precise.
Here is my Question:
I'm developing some project where I built some HTML and Javascript code dynamically with Java and load it into a Webview of JavaFX. The Html has to be generated dynamically because there are lots of Information in it that come up from a central database. Then I try to run it via a ChangeListener that is set on LoadWorker for the WebEngine of the Webview to ensure that the Webpage is loaded. The page is loaded correctly but when I try to use some javascript function the Application crashes.
The whole thing is working with a local written html document. In the Html are lots of Javascript-Libraries like Jquery and others. But my project crashes because the libraries and its functions cannot be used. I think that the http-Request of loading a local written html sets up these javascript when the webpage is loaded.
Am I correct with this?
And is there anything I can fix this Problem with dynamic generated htmls loaded in a Webview.
Thanks for any help!

Inject javascript in existing asp.net webforms app

I am currently working on a website which has a lot of javascript . How can i make sure that my javascript has the best chance of running properly? By adding another script section in the page or through asp.net registering the script?
You should read: http://msdn.microsoft.com/en-us/library/aa478975.aspx
By using the RegisterStartupScript() method on the server side Page_Load you can ensure that all of your HTML markup is loaded and ready to be modified. It is also good practice to put your javascript sections at the bottom of your form's markup if you want to access html elements, for example setting a textboxes text or something.
You can't really say one is "better" or has a "better chance of running properly" than the other, because you would use either/or depending on what you need to do. If you read the above link that I posted I think things will make a lot more sense for ya.
You only need to use ASP.NET to register the script if you're making changes to it server side. Other than that, put it in the <head> section.

Using asp.net ajax client side framework on a bare-bones HTML page

I want to use the asp.net ajax client side framework on a bare-bones HTML page. Firstly, is it possible? If yes, then can someone point me in the right direction?
Yes, it is possible. You need to include MicrosoftAjax.js and start using it. For further reference you can check the following links:
Microsoft Ajax Client Reference
Using Microsoft Ajax with PHP
In a word you need to include the file and start using the API. What exactly do you need from ASP.NET Ajax? Have you considered using jQuery instead? My experience tells that ASP.NET Ajax is suitable for ASP.NET only cases (web-forms, server controls, partial rendering etc) whereas jQuery is more close to the metal and works with all server platforms.

Categories