The reason you are not getting 'Run 3' is because Java is thinking about string concatination. As it is processing from left to right you would see: "Run 2" + 1 + "" But this is where it gets a bit strange, I would expect to see the number 1 printed next giving you: "Run 21" If you want to add two numbers you must use brackets to indicate priority: System.out.print("Run "+ (i+1));
Gerben Jongerius
Posts
-
Is it a bug or featuere -
Caching html pages - no thanks - but how?That's correct.
-
Caching html pages - no thanks - but how?This is not a serverside issue, cache control is arranged by the client. If the client suspects the content to be out of date the browser will sent a head request. The server then replies with status 200 if there is a new version. To disable caching on the browser you can set the following 2 headers:
Cache-Control: no-cache, must-revalidate Expires: Sat, 26 Jul 1997 05:00:00 GMT
This should disable browser cache. -
load page on scrolling in phpweb site by using jqueryAre trying to get some sort of loading like a story line of social sites, where more data is loaded when you scroll down. If so then you will have to create some sort of paging mechanism in the PHP side, so that jQuery can send ajax calls to load the next section of data. Your PHP site can then return the data based on the page provided by the ajax call.
-
redirect based on languageYou could try and base it on the 'Accept-Language' header that the browser sends to the website. This contains a list of preferred languages. See official W3 specifications[^] for more on how to use this header. But make sure to always have an option for users to change the default language on the site, or you might get angry users that don't want english even though their computer indicates it is the preferred language.
-
what are hidden links??If SEO is your goal then hiding links is one of the worst things to do and will get your site penalized into oblivion. The only valid reason for hiding links is when you have links in flash or image maps, as some bots don't parse these correct. This usage will also not have heavy penalties.
-
problem of a deployment in tomcat serverThe build script is already telling you what you should be doing next. Locate and look into the catalina.out file for more details as to why the web app failed to start. As to where the catalina log files are, that depends greatly on what type of Tomcat install this is. If it's integrated in Netbeans then it's located in the .netbeans/7.1.1/apache-tomcat/logs. If it is a debian / ubuntu based linux its found under /var/log/tomcat In either case the catalina log will show the root cause of the failure to start. But it's most likely something in the web.xml that is wrong.
-
WordPress Plugin ProblemAny good Wordpress plugin will do these type of changes for you, as there are 'hooks' available for this. But to help you out, you will need to edit the header.php file in the themes directory. This is located under wp-content/themes/[yourtheme]/header.php You will need to replace the [yourtheme] by the name of the theme you have activated for Wordpress (you should be able to see this in the wp-admin section). You can add the code to that file just above the tag. Alternatively you might want to look into the 'Ultimate Google Analytics', which has a very easy configuration.
-
1045 - Access denied for user "root@192.168.1.9" using password: YESIs this a VPS or dedicated server, if so have you verified that MySQL is even listening to external IP addresses. Most hosting providers will limit access to MySQL from outside the server itself. If you have a VPS or dedicated server look in the '/etc/mysql/my.cnf' And make sure the rule below is not applied or change it to your network IP address for that server.
bind-address = 127.0.0.1
-
1045 - Access denied for user "root@192.168.1.9" using password: YESSure just replace it with a '*' and you will grant access to all the schema's in the database.
-
1045 - Access denied for user "root@192.168.1.9" using password: YESYou need to add additional access rights by executing the following command in Mysql console line:
GRANT ALL on .* TO 'root'@'192.168.1.%'
This will allow all computers in the 192.168.1.x subnet to login to your MySQL server.
-
Deploy a Web Application Online.It is pretty simple and can be done in the following steps: 1. Rent or buy a webserver (or webhposting) package 2. Make sure you have Java support with your hosting provider 3. Ask them how to deploy a Java project with them, as this may be different per hosting provider
-
Display images from MySQL database using PHP help needed please !!!You will have to create a seperate PHP file that is able to load the image from the database and output it to the browser. You then set the '?' in the sample code you gave to that PHP file. The PHP script that will actually present the image to the browser will be something similar to this:
Note that you have to set the correct content type or the browser won't know what it is receiving. A full tutorial on storing images in a DB can be found at http://phpro.org/tutorials/Storing-Images-in-MySQL-with-PHP.html[^]
-
my Webservice dont work, what can be the problem ?Ok, so you will need to provide us with more information other then 'It aint working'. Here are some steps that might give you a clue as to what is wrong: - Look through the IIS access files, to see if the request to the service are giving status code 200 or 204 (if not the service is throwing an error, code 503) - Look through the webservice logs, if any, to see if it tells you what is wrong - Make sure you are calling the webservice right, keep in mind SOAP services require POST data in XML format.
-
Translater like google translateWell you could always include the google translate script somewhere in the page. That way users can change the language of the contents with just one click, as described at Google translate tools[^]. As to creating your custom translate engine, that would be a lot of work including: - scraping or buying multiple dictonaries for every language - linking words in dictionaries accross the various languages - finding a way to stem words to the basics - building a correct matching algorithm to match one word or group of words to another And even if you do all that (which is a lot of work) it will still probably work crappy. Though google translate is nice to sorta now what a page tells me (if it is in a foreign language) it is far from perfect. In fact most of the time the translations are more likely to be funny and wrong then right.
-
best way to determine mobile deviceThat would indeed work. If you put the entire function in the external php file and the code below in all files that need the check for mobile devices.
if (detect_mobile()) {
header('Location: blog');
}Please note though that the redirect that you put in you code would not work as is. You would need to replace the 'blog' part with a URL to the mobile site.
-
best way to determine mobile deviceYou could do either one of the two. But I would suggest creating a generic php file with this piece of code in a method. Including that php file in every page and calling that method. EG: dection.php <-- contains the check + redirect Sample index.php:
-
include questionYou can't do a cross server include like that. PHP include directive only works with files on the same webserver. The way I see it you have two options to solve this: * put the file on the same server and use normal include directives * use the file_get_contents or an iframe to load the external resource
-
Help me in configuring the PHP .How to run a PHP programEven if port 80 is in use that should not stop the installation of WAMP. You won't be able to startup WAMP until you close the other program using port 80. Usually this is skype, as this reserves port 80 and 8080 for outgoing and incoming traffic. You can try and locate the process by running
netstat -ob
.
-
How to use Tomcat instead of GlassFish with NetBeans?You need to right click the project go to the properties. Under Run you can select which application server you want to deploy the project to.