ASP pages not bringing in Images, CSS or JavaScript - javascript

My uncle's has got the files for his website that he got made a few years ago and needs something changed on it. So he has sent me the files as I am willing to make small changes as I know HTML and CSS. But when I open his index.asp page in a browser this only shows html even though the images, css and javascript files are linked properly.
I am not familiar with asp, I would really appreciate it if someone could let me know why the files are not being brought up when I open the index.asp file in a browser.
Thanks

Because when you just open the asp file on a browser, there's no web server intervention so that the ASP page is properly processed. You are just opening a file as if you were opening it on Notepad. You need to configure the whole site as an IIS Application and browse to the site by going to http://localhost/YourSite

First things first - as the previous comment says, you need to run ASP through an IIS based web site because the code needs to be processed.
If you're running through IIS and having this issue, check to see that your IIS settings are correct. Google "static content IIS" and you should find articles relating to this problem.

Related

Prevent users from reusing website source files (downloading is okay)

UPDATE:
Something's wrong with stackoverflow. It seems people couldn't read the first line of the question properly and they start preaching about "how websites can't be downloaded" which is not exactly the question. So here is the question in a more specific way:
How to get hosted server's IP address (or any other information which is unique to the hosted server) using jQuery. Googling doesn't help much.
Now, please don't start with "getting client's IP address" or "this can't be done". I know this is nearly impossible; but if someone can get me close to the idea, that'll do.
Oringinal Question:
I know users can download the source files if they can see it in their browser. What I am trying to do is stop them from reusing it. Like checking IP of hosted server and redirecting to the original domain if the files are hosted in a different server.
Using PHP (or any server programs) won't do as the end user will be getting the final html/css/js files.
Basically, I don't want anyone to download and host/reuse website files.
Thanks in advance.
Javascript is code, and can be obfuscated. This makes it so difficult to maintain that it's usually easier for the end user to re-write from scratch. Try Googling for "Javascript Obfuscator".
With HTML and CSS, it's pretty much open to the user. Not much you can do about that!
If you make website in PHP you will write some code that gets translated into end-html that user can view and download. So your source file in PHP is unreachable for end-user. Like in Wordpress your code could be only few rows and end html could be hundreds of rows long because it reads data from a database and puts it into html.
If you write scripts in javascript you can not protect it from downloading and reusing that.
This can't be helped. If the viewer can view your website he can download the front-end of the website.
If your worried about someone downloading your server-side scripts, you don't have to because server side cannot be downloaded through the front-end.

how to view source code for javascript src

I apologize in advance if this question is not appropriate for this forum. I could not find answers from searches in Google or Stackexchange. Also, because the question was specific, I thought I might be acceptable.
Background:
The end purpose is to troubleshoot a server connection error where a client machine runs javascript. I'm trying to at least determine the source and destination network ports used for the communication attempt.
I know zero javascript but have some background in C++.
The client runs this html page:
<script type="text/javascript" language="javascript" src="com.vmware.vim.cimmonitor.gwt.CimUi.nocache.js"></script>
Is there a way to view the contents of the specific js file? I cannot tell if the js file is bundled locally in some kind of javascript library or resides somewhere in vmware.com
I've tried to directly enter the full js name into firefox, but got a server not found error.
Thanks.
Press F-12 to open the browser's debugger. Open the NETWORK section. Reload the page. It will show you a complete list of resources as they are loaded. You can click on any of these to look at the source and http header information.
Unless the js code is using websockets, communication is likely just http:// on port 80.
if you use the developer console in chrome/safari, you can view all loaded javascript in the resources tab.
you can also use netstat to see what active port connections you have.

How to show browse for FOLDER window(not browse for file)using just JSP and javascript?

I need a code for how to browse for folder (not file) using JSP and Javascript.
I looked for the JAVA code for browse for folder using JFileChooser library but I want the default window to be opened (which opens in browse for file).
I'm developing a webapp which will scan the folder based on the path and will generate the output.
Thanks in advance.
1.I need a code for how to browse for folder (not file) using JSP and Javascript.
Javascript does not have access to the file-system due to security reasons, as this answer says and also this answer.
So you would have to use flash or java applet as suggested in this answer or else you would have to wait till the time HTML5 File API matures :-)
But, if your requirement is that your a User (may be with administrator rights in the application) logins to the web-application through a web-browser and wants to scan (view the contents of) the particular folder on the server side (where the web-app is deployed and not the file system on his own machine) then you can use the suggestion given in this answer, just to elaborate on this:
Have a <form> which will have a text-box (to take the folder name or full-path) in the JSP, on submit of this form a request will be sent to the server.
The response would be list of files (List<String>) in that particular folder passed through the request.
you can also submit the request through ajax in which case you would return a JSONArray as suggested.
Now on the Server it would be normal Java File API stuff to fetch all the files in the folder you get from the request.
Sorry to say this but I don't think you would get a ready-made code to do what you want and that is not how things work on SO.
2.I looked for the JAVA code for browse for folder using JFileChooser library
You said you are building a web-app right? JFileChooser is a Swing component and as far as I know cannot be used in JSP to achieve what you desire.
3.I'm developing a webapp which will scan the folder based on the path and will generate the output.
The steps are explained in point (1).
Hope this helps and gives relevant hint and direction to go forward.

Open local html file in current window with Javascript Bookmarklet

I'm trying to build a sample bookmarklet to grab current webpage source code and pass it to a validator. Validator is not a an online website, but a folder with bunch of javascript and html files. I'm trying to open file:///C:/Users/Electrifyings/Desktop/Validator/Main.html file with the help of javascript bookmarklet code and put the source code in the textarea in the newly opened window, but it is not working for some reasons that I'm not aware of.
Here is the sample code with algorithm:
javascript:(function(){var t = document.body.innerHTML;window.open('file:///C:/Users/RandomHero/Desktop/test.html',_self);document.getElementById("validator_textarea")=t;})()
Here are the steps:
Grab current web page source code in a variable.
Open locally stored HTML web page in current or new window or new tab (either way is fine with me, but no luck)
Put the source code from the variable into the validator textarea of the newly opened HTML file.
I have tried above code with a lot of variations, but got stuck on the part where it opens the new window. Either it's not opening the new window at all or it is opening blank window without loading the file.
Would love to get some help with this issue, thanks a lot.
Oh and btw,
Windows 7 x64, Tried IE, Firefox and Chrome. All latest and stable builds. I guess it's not a browser side issues, but something related to javascript code not opening the URI with file:/// protocol. Let me know if any more details are needed. :)
You wouldn't want a webpage you visit to be able to open up file://c:/Program Files/Quicken/YourSensitiveTaxInfo right? Because then if you make a mistake and go to a "bad" website (either a sleazy one or a good one that's been compromised by hackers), evil people on the intarweb would suddenly have access to your private info. That would suck.
Browser makers know this, and for that reason they put VERY strict limits to prevent Javascript code from accessing files on a user's local computer. This is what is getting in the way of your plan.
Solutions?
build the whole validator in to the bookmarklet (not likely to work unless it's really small)
put your validator code up on the web somewhere
write a plug-in (because the user has to choose to install a plug-in, they get much more freedom than webpages ... even though for Firefox, Chrome, etc. plug-ins are basically just Javascript)
* * Edit * *
Extra bonus solution, if you don't limit yourself to a purely-client-side implementation:
Have your bookmarklet add a normal (HTML) form to the page.
Also add an iframe to the page (it's ok if you hide it with CSS styling)
Set the form's target attribute to point to the iframe. This will make it so that, when the user submits the form and the server replies back to that submission, the server's reply will go to the (hidden) iframe, instead of replacing the page as it normally would.
Add a file input to your form - you won't be able to access the file within that input using Javascript, but that's ok because your server will be doing the accessing, not your bookmarklet.
Write a server-side script which takes the form submissions, reads the file that came with it, and then parrots that file back as the response. In other words, you'll have a URL that you can POST to, and when it sees a file in the POST's contents, it will respond back with the contents of that file.
Now that you've got all that the user can pick their validator file using the file input, upload it to your server, your server will respond back with the file it just got, and that file will appear as the contents of the iframe.
And now that you finally have the file that you worked so hard to get (inside your iframe) you can do $('#thatIframe').html() and viola, you have access to your file. You can save the current page's source and then replace the whole page with that uploaded file (and then pass the saved page source back to the new validator page), or you can do whatever else you want with the contents of the uploaded validator file.
Of course, if the file doesn't vary from computer to computer, you can make all of that much simpler by just having a server that sends the validator file back; this could be a pure Apache server with no logic whatsoever, as all it would have to do is serve a static file.
Either way though, if you go with this approach and your new file upload script is not on the same server as your starting webpage, you will have a new security problem: cross-domain script limitations. However, these limitations are much less strict than local file access ones, so there are ways to work around them (JSONP, cross-site policy files, etc.). There are already tons of great Stack Overflow posts explaining these techniques, so I won't bother repeating them here.
Hope that helps.

How can I see included JavaScript sources?

I am trying to script a web page using GreaseMonkey. (I am using Firebug for help in development.) The page has a small amount of JavaScript code, but that code pulls in other JS files from the site. Are the entire collection of JS files stored somewhere on the client side (i.e. on the filesystem somewhere) so that I can view them? Or better yet, is there a way I can view them in Firebug? I am a little overwhelmed by Firebug but will be able to follow instructions.
Click the script tab in Firebug. Then look immediately below the tab for a dropdown that shows all the scripts.
right click - view source

Categories

Resources