AniMate bY Javascript : JavaScript

logo


To make the webpage dynamic we use animation. This animation can be implemented using both CSS and JavaScript. Here’s how to use JavaScript animation in webpage.

How does it work?

The idea behind the JavaScript-based animation is fairly simple, a number of DOM elements (< /img>, < /div > or otherwise) are moved around the page according to some sort of pattern determined by a logical equation or function.
You can use JavaScript to create a complex animation having following elements,
  • Fireworks
  • Fade effect
  • Roll-in or Roll-out
  • Page-in or Page-out
  • Object movement
An existing JavaScript animation library

JavaScript provides the following two functions to be frequently used in animation programs.
  • setTimeout( function, duration) − This function calls function after duration milliseconds from now.
  • setInterval(function, duration) − This function calls function after every durationmilliseconds.
  • clearTimeout(setTimeout_variable) − This function calls clears any timer set by the setTimeout() functions.
JavaScript can also set a number of attributes of a DOM object including its position on the screen. You can set top and left attribute of an object to position it anywhere on the screen. 
 Here is its syntax.

// Set distance from left edge of the screen.
object.style.left = distance in pixels or points;

or

// Set distance from top edge of the screen.
object.style.top = distance in pixels or points;

Manual Animation

We are using the JavaScript function getElementById() to get a DOM object and then assigning it to a global variable imgObj.
We have defined an initialization function init() to initialize imgObj where we have set its position and left attributes.
We are calling initialization function at the time of window load.
Finally, we are calling moveRight() function to increase the left distance by 10 pixels. You could also set it to a negative value to move it to the left side.
Click here to get the code!

function moveRight1(){ var imgObj1 = null; imgObj1 = document.getElementById(‘myImage’); imgObj1.style.position= ‘relative’; imgObj1.style.left = ‘0px’; imgObj1.style.left = parseInt(imgObj1.style.left) + 250 + ‘px’; }


Click button below to move the image to right

Automated Animation

In the above example, we saw how an image moves to right with every click. We can automate this process by using the JavaScript function setTimeout() as follows −
Here we have added more methods. So let’s see what is new here −
  • The moveRight() function is calling setTimeout() function to set the position of imgObj.
  • We have added a new function stop() to clear the timer set by setTimeout() function and to set the object at its initial position.
Click here to get the code!

var imgObj = null; var animate ; function init(){ imgObj = document.getElementById(‘myImage1’); imgObj.style.position= ‘relative’; imgObj.style.left = ‘0px’; } function moveRight(){ imgObj.style.left = parseInt(imgObj.style.left) + 10 + ‘px’; animate = setTimeout(moveRight,20); // call moveRight in 20msec } function stop(){ clearTimeout(animate); imgObj.style.left = ‘0px’; } window.onload =init;


Click the buttons below to handle animation

Rollover with a Mouse Event

Here is a simple example showing image rollover with a mouse event.
Let’s see what we are using in the following example −
  • At the time of loading this page, the ‘if’ statement checks for the existence of the image object. If the image object is unavailable, this block will not be executed.
  • The Image() constructor creates and preloads a new image object called image1.
  • The src property is assigned the name of the external image file called /images/html.gif.
  • Similarly, we have created image2 object and assigned /images/http.gif in this object.
  • The # (hash mark) disables the link so that the browser does not try to go to a URL when clicked. This link is an image.
  • The onMouseOver event handler is triggered when the user’s mouse moves onto the link, and the onMouseOut event handler is triggered when the user’s mouse moves away from the link (image).
  • When the mouse moves over the image, the HTTP image changes from the first image to the second one. When the mouse is moved away from the image, the original image is displayed.
  • When the mouse is moved away from the link, the initial image html.gif will reappear on the screen.

if(document.images){ var image1 = new Image(); // Preload an image image1.src = “https://pbs.twimg.com/profile_images/741523114278916096/7bL6w5dy.jpg”; var image2 = new Image(); // Preload second image image2.src = “http://suvenconsultants.com/mainpagefiles/images/training.jpg”; }

Move your mouse over the image to see the result:

Click here to get the code!




Learn Web Technologies!


What China is doing to create a tech edge over the US

It used to be that any time a product bore the all-too-familiar ‘Made In China’ stamp, it was a sign of poor-quality. How things change. These days, China doesn’t just create cheap toys and the flotsam of the past. Nor does it just assemble devices for Apple, or make clothes for Nike.

China manufactures over 70 percent of all smartphones. Chinese brands accounting for half of the world’s market share. China also produces 80 percent of the world’s solar panels, air conditioners, PCs, and much more. It’s the world’s industrial powerhouse. Block miners in China are even estimated to control around 80 percent of the Bitcoin network hash rate.

There are two regions dominating the digital world and they’re both on the Pacific ocean. The West Coast of the U.S. houses Apple, Google, Facebook, Amazon, Tesla, Illumina, Silicon Valley, San Francisco, Seattle, and Los Angeles. The East Coast of China is home to Tencent, Alibaba, Baidu, and Shenzhen.

Once strictly an importer of foreign technology, China has now become an exporter. The country set the new record for filing the most patents in a year, growing its patent filings more rapidly than any other top 10 country.

The Boston Consulting Group (BCG), together with divisions from Alibaba, Baidu, and Didi, noted in a September report just how fast Chinese tech companies are reaching unicorn status— achieving a valuation of over $1 billion.

According to the report, these companies take just four years to hit the magical $1 billion mark, on average. In comparison, U.S. companies take seven years. 46 percent of these Chinese-founded unicorns get there in two years, compared to just nine percent in the U.S.. The number of unicorns is almost on par, too. Deloitte and China Venture’s sixth Sino-US Unicorn Research Report revealed, China has just under 40 percent of world’s unicorn corporations. The U.S. tops the list with just over 42 percent. Third-place was India, which accounts for only four percent.

China recently set the new record for filing the most patents in a year, growing its patent filings more rapidly than any other top 10 country.

Part of the reason for this is the natural size of the Chinese and U.S. markets, internet user growth rates (increases in which are conducive to the creation of new start-ups), and gaps in the market. While some U.S. tech giants are expanding overseas —Google just announced a new AI research center in Beijing— we’ve yet to see aggressive moves from Chinese giants beyond some moves into India. That appears to be at least partly down to the ongoing development of China’s own market, where internet penetration is just over 53 percent.

These new Chinese unicorns are popping up far quicker and far bigger than U.S.-based ones, and it’s these that will shape the disruptive forces of the future domestically and eventually all over the world.

So how did we get here?

Open-source information

Open-source and sharing of information plays a bigger role in China than in the United States.

In the U.S., patents and copyrights once designed to protect intellectual property (IP) are now often used to aggressively hunt down infringements and seek damages, which stifles creativity and development. The idea of working together and sharing ideas is fostered by students and hobbyists, but not in corporate environments. The open-source world of software hasn’t found much uptake in hardware.

Editor’s Pick

According to Managing Director of Shenzhen-based Hax Hardware Accelerator Duncan Turner, patents aren’t created in China to fight copycats and exert legal pressure, they’re used for trades between companies to share information.

The Chinese counterfeit consumer goods industry, which are known as ‘Shanzhai’ in China, has been a key for domestic skill creation. The industry operates largely in a legal grey area, and a number of serious cases of IP theft has been made it a hot topic for companies, and increasingly political.

Unlike in the US, patents aren’t created in China to fight copycats and exert legal pressure, they’re used for trades between companies to share information.

The Shanzhai industry has showcased the skills of engineers and designers who manufacture near-identical devices to leading brands at far lower costs. Yet as China’s middle class class gains more purchasing power, they are increasingly after genuine brands, which has changed the nature of Shanzhai businesses.

Though the Shanzhai model was once the only way for Chinese entrepreneurs sell devices in their once-poor country, a different path is opening. Moving with the same speed and mindset as before, many of these companies are now focused on the creation of new cutting-edge products and brands, with innovative and increasingly influential ideas. Wired’s 2016 documentary, Inside Shenzhen: The Silicon Valley of hardware, featured names like Andrew ‘Bunnie’ Huang, Seeed Studio founder and CEO Eric Pan, David Li, Richard Chiang, and many more, and showed the incredible depth of electronics manufacturing, making, and hacking that made Shenzhen as it is today.

Customer-to-business innovation

A separate BCG report highlighted ‘customer-to-business’ innovation in China, where product ideas come from customers through feedback, as well as intent and data analysis. These ideas are quickly produced, and can be just as quickly removed if unpopular.

This is different to the traditional model, where US companies create products based on more limited data and hope it will sell. The Chinese tech ecosystem is also far more concentrated and geared toward rapid action. It’s able to turn concepts into prototypes in days or weeks, rather than months.

In 2016, China’s online marketplace users generated 20 million product reviews and 2 million questions about products every day.

The BCG report details the incredible depth of data gathered by major Alibaba ecommerce marketplaces Taobao and Tmall. These sites are different to our familiar Amazon marketplace and focus on a rich experience over efficiency. Where Amazon users favor one-click, fast shipping, Taobao and Tmall offer entertainment, social sharing, and community. Alibaba has insisted it is in the social commerce business, rather than e-commerce.

In 2016, these marketplaces’ users generated 20 million product reviews and 2 million questions about products every day. Users spend much more time on these sites, often visiting them more than seven times a day. This makes them mega-hubs for data in a country with fewer Government restrictions on the collection and use of data. This allows for greater personalization and recommendations, and also helps businesses create and tweak new products based on deeper consumer insights.

Diversity

Gender diversity is technology is a hot topic. Although not telling the full story, a simple comparison between Uber and Chinese ride-sharing app of choice, Didi Chuxing, offers some insight: At Didi, women occupy over 37 percent of its tech staff. Uber, cruelled by toxic culture claims, sits at just 15 percent.

Alibaba’s founder, Jack Ma, said at a conference earlier in the year that women were the ‘secret sauce’ to the company’s success, while urging firms to copy his playbook and “hire as many women as possible”. More than one-third of Alibaba’s founders are women, and a similar percentage hold senior management roles.

China’s authoritarian regime doesn’t offer a bastion of freedom and open-doors for skilled foreigners to consider immigration, but some laws have changed to fast-track highly-skilled professionals. Hugo Barra’s tenure at Xiaomi helped it grow from being just a domestic Apple-clone company to one with a global presence.

More work needs to be done to welcome more diversity into the workforce, but as many Chinese University students unable to find work, the country has to strike fairly fine balance.

In the U.S., many of Silicon Valley’s top companies have been founded or run by immigrants or the children of immigrants. This includes Steve Jobs at Apple, Sergey Brin at Google, Microsoft CEO Satya Nadella, and many more. It’s clear that making your country attractive to the world’s best and brightest is a competitive advantage—as Nadella says himself:

Changes pursued by the Trump administration are putting this advantage at risk.

China: The meteoric rise continues

China’s growth has underpinned the global economy. Its efforts to gain equal footing with the West has spurred a middle class bigger than the entire U.S. population and created tremendous business opportunity.

That same growth is spurring China’s technology and digital firms to go further. As China’s unicorns catch up to those of the United States, the race to become biggest and best is on.

The Smart Weapons Fallacy: Civilian Casualties From ‘Precision’ Air Strikes in Iraq and Syria

There’s no such thing as a smart bomb.

The final elimination of Isis in Iraq and Syria is close, but welcome though the defeat of these monstrous movements may be, it has only been achieved at the cost of great destruction and loss of life. This is the new face of war which governments try to conceal: a limited number of combat troops on the ground call in devastating air strikes from planes, missiles and drones, be they American or Russian, to clear the way for their advance.

Governments pretend that air wars today are very different from Vietnam half a century ago when towns were notoriously “destroyed in order to save them”. These days air forces – be it the Americans in Iraq, the Russians in Syria or the Saudis in Yemen – say that this mass destruction no longer happens thanks to the greater accuracy of their weapons: using a single sniper, a room in a house can supposedly be hit without harming a family crouching in terror in the room next door.

The sale of vastly expensive high precision weapons to countries such as Saudi Arabia is even justified as a humanitarian measure aimed at reducing civilian casualties.

The PR has changed but not the reality. Despite the claims of enhanced accuracy, drone pictures of west Mosul look very much like pictures of east Aleppo, Raqqa or large parts of Damascus where every building is gutted or reduced to heaps of broken bricks interspersed with craters. The problem for journalists or human rights organizations is that it is almost impossible to verify the claims of victims or the denials of alleged perpetrators at the time.

Witnesses, when they are not dead, have often fled or are too frightened to speak; governments, regular armies and air forces will probably get away with it if they stick to a straight denial that they have done anything wrong. Even if damaging information does eventually come out, the news agenda will have moved on and public interest will be slight.

I found it frustrating during the final weeks of the siege of Mosul, which went on for nine months, to know that there was very heavy civilian loss of life as Iraqi forces backed by air strikes closed in on the Old City, but it was impossible to prove it. I was in touch by mobile phone with two different individuals trapped behind Isis lines who faced the dilemma of either staying where they were and chance being killed by the bombardment, or trying to escape to government-held territory and risk being shot by Isis snipers.

The two men took different decisions, but neither of them survived. One was shot dead by Isis as he and his mother joined a group trying to escape across the Tigris using rubber tires because they could not swim. A second man was wounded in one air strike and killed by a second in the last weeks of the siege. Most of the two men’s extended families were also dead by the time the siege ended.

Fortunately some reporters do go on looking at what really happened in battles like Mosul long after the rest of the media has shifted its attention elsewhere. Joel Wing, in the online journal Musings on Iraq, writes that fresh information on casualties raises “the total number of dead during the operation [to capture Mosul city and surrounding area] to 21,224 and 30,996 wounded. 17,404 of the former and 24,580 of the latter occurred in Mosul. The new numbers still highlighted the fact that there are many more undocumented casualties as the wounded should be four to six times higher than the fatalities figure. Even if you subtract the 5,325 people that were executed by the Islamic State, that would still mean there should be 60,000-90,000 injured from the fighting.”

The figure looks high but is credible, taking into account the use of conventional artillery and Russian multiple rocket-launchers in the attack on west Mosul. Casualties from air attack also went up because the rules on ground troops calling in air strikes were relaxed before the attack on west Mosul began. Isis was killing civilians who tried to escape from the shrinking Isis-held enclave and more people were confined in fewer houses so if one was hit the loss of life would be high.

Even before this happened many more civilians were being killed by air strikes than the US-led air coalition was admitting. The only way to get at the truth is to look at a large sample of air strikes on the ground and see if they were reported by the coalition and, if so, how accurate that reporting was.

This has now been done for the first time by Azmat Khan and Anand Gopal, who visited the sites of nearly 150 air strikes in northern Iraq between April 2016 and June 2017. In a lengthy study called “The Uncounted”, published in The New York Times on 16 November, they reached devastating conclusions. They write that “we found that one in five of the coalition strikes we identified resulted in civilian death, a rate more than 31 times that acknowledge by the coalition”. They add that when it comes to civilian deaths this “may be the least transparent war in recent American history”.

The coalition denied that many of the air strikes that had killed people had ever taken place, but the reporters found that there were videos of several of them on the coalition’s YouTube channel, though these claimed to show the destruction of Isis targets. When they pointed this out, the videos were quietly withdrawn.

The picture that the coalition presented of its air offensive turns out to be a fabrication. In one sample of a residential area called Qaiyara, near Mosul city, the coalition claimed it had killed only one civilian in or near the town and the Iraqi air force said it had killed nobody. It turned out that there had been 40 air strikes on this area which had killed 43 civilians, of whom 19 were men, eight women and 16 children aged 14 or younger. In about a third of fatal strikes Isis had been in close proximity to the civilians, but in half of the cases there had been no discernible Isis presence.

Where there was evidence of Isis it was often flimsy and out of date: in one case a family of six was wiped out aside from a two-year-old child because a local informant had once seen a mortar near their house though it had been moved long before the strike.

The significance of the study is great because for the first time it can be shown what is really happening in a series of wars in the Middle East starting with Afghanistan in 2001. There is no such thing as precision air strikes.

The coalition claimed that only one in 157 of its 14,000 air strikes in Iraq since 2014 have caused a civilian death, but the evidence on the ground shows the real rate to be one in five. The comforting claim by American and British air commanders that smart weapons enable them to avoid killing civilians is simply untrue.

 

 

Related Stories

  • The Forgotten Syria Crisis: How the World Profits Off of War
  • Give Your Values This Holiday Season: Buy Mexican
  • Communists Sweep the Nepali Elections, a Blow to The Establishment Parties

Ordered a new 3D printer

I’ve been using my XYZ da Vinci Junior 1.0w 3D printer for a year now. It is still working. However I have learned a lot during that year, I’m printing more complicated models now, and I’m reaching the limits of what the machine can do. I still think it is a great printer for a beginner, but now I want something much better. So I ordered a Zortrax M200 Plus. The “Plus” is important, as this is the brand-new and improved model of the M200, which is highly regarded but now 5 years old.

The first difference between the two printers is the price. The da Vinci Junior was 471€, the Zortrax M200 Plus is 2,369€. Obviously not the same league. The da Vinci Junior uses PLA, the Zortrax can use PLA, ABS, and some other materials. The old M200 was really best used with ABS, but the new Plus version has better cooling fans, so PLA should come out fine now as well. The main difference is that the XYZ printer was only able to use proprietary XYZ filaments, while the new Zortrax also works with filaments from other suppliers. That was a major point of annoyance for the old printer for me; the spools came with an RFID chip, and if the chip said your spool was empty, the printer refused to use the spool. As the chip counted loading, unloading, and failed prints as lost material even if there was no actual material lost, I always ended up having to throw away the last meters of the spool. And the material was far more expensive than it should have been. However at the start I’ll use Zortrax ABS, just because the software knows the best settings for that material.

Where the difference between the two printers is likely to be biggest is in the quality of the prints. At the shop where I ordered the printer they had sample prints of little miniatures similar to those I often make, and the quality was *much* better. On the best setting you don’t even see the layers any more with the Zortrax M200 Plus. Of course it remains to be seen how good it will work with my prints. But the experimenting and fiddling around is all part of the hobby, the resulting miniatures are more of a secondary benefit. 🙂

From what I see in reviews the main issue with the Zortrax is that the software is very slow. I saw a YouTube video of a guy using the old Zortrax M200 to print a Harry Potter wand, and the software took 25 minutes to slice that model. That has probably to do with the print being with rafts (mandatory with the Zortrax) and supports. I suspect the supports use a lot of slicing time, I’ll have to try with and without it. But from the video it appears that the supports are easy to remove, which could be a plus. Now I finally understand the models of Miguel Zavala: Many of them can’t be printed without those automatically generated supports, and the supports generated by the XYZ software are very bad. So up to now I had to fiddle around with the models a lot, disassemble them digitally, reassemble them digitally, and generate functional supports with Meshmixer. I might be able to just hit a print button in the future, which will be faster even if the slicing is slow.

I’ll let you know how the new printer works out once it is delivered and installed.

How to install and configure TOMCAT server with Eclipse?

Download and Install Tomcat

For Windows
  1. Go to http://tomcat.apache.org ⇒ Under “Tomcat 8.5.{xx} Released” (where {xx} is the latest upgrade number) ⇒ Downloads ⇒ Under “8.5.{xx}” ⇒ Binary Distributions ⇒ Core ⇒ “ZIP” package (e.g., “apache-tomcat-8.5.{xx}.zip“, about 9 MB).
  2. Create your project directory, say “d:myProject” or “c:myProject“. UNZIP the downloaded file into your project directory. Tomcat will be unzipped into the directory “d:myProjectapache-tomcat-8.0.{xx}“.
  3. For ease of use, we shall shorten and rename this directory to “d:myProjecttomcat“.
Take note of Your Tomcat Installed Directory. Hereafter, I shall refer to the Tomcat installed directory as.
For Mac OS
  1. Go to http://tomcat.apache.org ⇒ Under “Tomcat 8.5.{xx} Released” (where {xx} is the latest upgrade number) ⇒ Downloads ⇒ Under “8.5.{xx}”⇒ Binary distribution ⇒ Core ⇒ “tar.gz” package (e.g., “apache-tomcat-8.0.{xx}.tar.gz“, about 9 MB).
  2. To install Tomcat:
    1. Goto “~/Downloads“, double-click the downloaded tarball (e.g., “apache-tomcat-8.0.{xx}.tar.gz“) to expand it into a folder (e.g., “apache-tomcat-8.0.{xx}“).
    2. Move the extracted folder (e.g., “apache-tomcat-8.0.{xx}“) to “/Applications“.
    3. For ease of use, we shall shorten and rename this folder to “tomcat”.
Take note of Your Tomcat Installed Directory. Hereafter, I shall refer to the Tomcat installed directory as .

For academic learning, I recommend “zip” (or “tar.gz”) version, as you could simply delete the entire directory when Tomcat is no longer needed (without running any un-installer). You are free to move or rename the Tomcat’s installed directory. You can install (unzip) multiple copies of Tomcat in the same machine. For production, it is easier to use the installer to properly configure the Tomcat.

Create an Environment Variable JAVA_HOME

(For Windows)
You need to create an environment variable called “JAVA_HOME” and set it to your JDK installed directory.
  1. First, find your JDK installed directory. The default is “c:Program FilesJavajdk1.8.0_{xx}“, where {xx} is the upgrade number. Take note of your JDK installed directory.
  2. To set the environment variable JAVA_HOME in Windows 7/8/10: Start “Control Panel” ⇒ System and Security (Optional) ⇒ System ⇒ Advanced system settings ⇒ Switch to “Advanced” tab ⇒ Environment Variables ⇒ System Variables ⇒ “New” ⇒ In “Variable Name”, enter “JAVA_HOME” ⇒ In “Variable Value”, enter your JDK installed directory as noted in Step 1.
  3. To verify, RE-START a CMD shell (restart needed to refresh the environment) and issue:
    SET JAVA_HOME
    JAVA_HOME=c:Program FilesJavajdk1.8.0_{xx}

How to configure tomcat server in Eclipse IDE?

In Eclipse IDE, go to menu Window > Preferences. Then expand the Server > Runtime Environments node in the Preferences dialog:

Click Add… to add a new server runtime environment. In the New Server Runtime Environment dialog, select Apache > Apache Tomcat v x.x  and check the option Create a new local server:

Click Next. In the next screen, click the Browse button to specify the existing installation directory of Tomcat on your computer:

Click Finish, the selected Tomcat installation is added to the list of server runtime environments, as shown below:

Click OK to close the Preferences dialog, the new server runtime is added to the Servers view:

You can now drag and drop a project into this server in order to deploy and run the project.
NOTE: If you don’t see the Servers view, you can show it by go to the menu Window > Show View > Others…, then look for Servers.

Writing First Servlet:

1. Create Dynamic Web Project

To create a Servlet we need to create a new ‘Dynamic Web project’ which can be done in three ways,

  • Right click on Project Explorer -> New -> Dynamic Web Project
  • File menu -> New -> Dynamic Web Project
  • Click on the down arrow on New icon on toolbar -> Dynamic Web Project

 Click “Next” button.Click “Next” button.

Check ‘Generate web.xml deployment descriptor’ checkbox and click “Finish” button and Eclipse IDE will generate the web project automatically as shown below

2. Create Servlet Class

Select from the menu File –> New –> Servlet.

Write “com.srccodes.example” in the ‘Java Package’ field and “HelloWorld” in the ‘Class Name’ field. Click ‘Next’ button.

We can specify deployment descriptor (web.xml) specific information in the following screen. Just keep every thing as it is for the time being. Click “Next” button.

Click ‘Next’ button.Click ‘Next’ button.
Eclipse will generate a Servlet class based on the configuration / input we provided in the previous steps.
3. Write Custom Code

Add your code inside ‘doGet’ method. ‘setContentType’ method of HttpServletResponse sets content type of the response to ‘text/html’ which is the standard MIME content type for Html pages. ‘getWriter’ method of the response object returns a PrintWriter object. This will be used to print our “Hello World!” string in the browser.
Edit the generated ‘HelloWorld.java’ as per the following code.

File: HelloWorld.java

package com.srccodes.example;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Servlet implementation class HelloWorld
 */
@WebServlet(“/HelloWorld”)
public class HelloWorld extends HttpServlet {
    private static final long serialVersionUID = 1L;
        
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HelloWorld() {
        super();
        // TODO Auto-generated constructor stub
    }
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType(“text/html”);
        PrintWriter printWriter  = response.getWriter();
        printWriter.println(“

Hello World!

“);

    }
    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }
}

4. Run Your Servlet Code

Right click on the project ‘HelloWorldServlet’ and select from context menu ‘Run As’ –> ‘Run on Server’.
Select the existing tomcat server.
Click “Finish” button. HelloWorldServlet web application will be deployed in the tomcat web server.
6. Browser Output

Eclipse will open a browser and your server side code will print ‘Hello World!’ in the browser.

Wondering what comes next

The liberal world order has been defined as standing for “greater individual freedom, greater choice, support for democratic forms of government, a fundamental faith in free-market capitalism and private enterprise, a belief in constitutional forms of government with divided powers, an independent judiciary, separation of church and state, a strong support for free trade and an aversion to protectionism, among other things”. Obviously there is a lot to like about these values. Most economists believe that this system is the one that is best suited to the creation of wealth. However the predominance of the liberal world order in the last 30 years has also demonstrated that while the system is good for the creation of wealth overall, it isn’t all that good in the distribution of that wealth. That not only leads to a lot of opposition, but is also somewhat self-defeating in the long run: Concentrated wealth is less good at further powering the economy than distributed wealth.

In the USA and a lot of other places the current main opposition against the liberal world order comes from the right, from nationalism, protectionism, populism, and ethnocentrism. However if you look at those right-wing forces enacting policies like the current US tax reform or the Brexit from the UK, it is likely that the right will not solve the problem of wealth distribution any better than the liberal world order (and will presumably create less wealth in the first place). Blaming foreigners and the media will only get right-wing politicians so far until the people realize that they aren’t in fact “better off than they were four years ago”. It is that, and not the whole lot of unrelated shouting about various values, that ultimately will bring change. The liberal world order failed the people, but the conservative version isn’t doing any better. So I’m wondering what will come next.

One likely answer is in the form of people like Bernie Sanders and Jeremy Corbyn. The economic left might one day look like a good answer to people whose main concern is wealth distribution, because the economic left has always stood for redistribution of wealth. However the economic left also has some policies in their book that hinders wealth creation more than necessary for a fair distribution. And they have a long history of ending up with “more equal than others” policies that aren’t in fact much closer to a fair distribution of wealth than the conservative version.

What an optimist could hope for would be a reformed liberal world order, the same values as above but with a priority for wealth distribution and against too much wealth concentration. A vision like in Robert Reich’s Saving Capitalism. However if you look at how the world previously solved excesses of wealth creation, there are only few examples of peaceful solutions (e.g. Theodore Roosevelt) and lots of examples of the wealth ending up destroyed or redistributed through war and revolution. A pessimist would buy gold coins instead of bitcoins.

The Right-Wing Backlash Against #MeToo Is Coming Sooner Than You Think

Conservatives are angry and scared. This can only end badly.

At first blush, the story about Texas associate deputy attorney general Andrew Leonie, who resigned hastily after making ugly comments about the #MeToo movement on Facebook, seems like another sign of a sea change happening in the United States when it comes to sexism. But for me, it only adds to the growing sense of dread that another shoe is lifting and that the big drop is coming soon, and it’s going to be a bad one.

Sexists are getting angry. They’re getting scared. They’re starting to lash out. I worry that it’s just a matter of time before some of their punches start landing.

Leonie, who identified as a man of “Christian faith” and father to “great kids” on his Facebook page, also took to Facebook at 2:40 a.m. on a Wednesday morning and wrote, “Aren’t you also tired of all the pathetic ‘me too’ victim claims? If every woman is a ‘victim,’ so is every man. If everyone is a victim, no one is. Victim means nothing anymore.”

It’s tempting to believe that a man who was making more than $150,000 a year representing the great state of Texas in court is merely another casualty who failed to follow the rule that there’s nothing worth saying on social media between the hours of midnight and 6 a.m. But, as Noor Al-Sibai of Raw Story noted, Leonie had a habit of saying gross things on social media, including posting a cartoon calling the Women’s March protesters “cunts.”

Leonie was shown the door with haste, even though he’s in Texas and works for Attorney General Ken Paxton, a profoundly misogynistic politician who whined that Texas would become a “sanctuary state for abortions” if undocumented immigrants were legally allowed to terminate unwanted pregnancies.

Despite many fears to the contrary, it does seem that the #MeToo movement is affecting Republican careers. Rep. Trent Franks, R-Ariz., was pushed out after it was discovered that he tried to pay female aides to have babies for him. Rep. Blake Farenthold, R-Texas, has agreed not to run again, and is getting increasing coverage for his alleged harassment of employees. Alabama Republican Roy Moore lost his Senate bid after multiple allegations that he chased high school girls in his 30s came out. Now this Texas lawyer has been pushed out simply for saying gross things about sexual harassment victims.

It’s heartening, but let’s be clear: The only reason this is happening is that conservatives haven’t yet figured out a narrative they can use to derail the #MeToo movement. Part of the problem is that for decades, conservatives have argued against feminism by embracing the “chivalry” narrative, framing women as inherently weaker and in need of male protection. So while they won’t accept feminist arguments about sexual harassment being a matter of sex discrimination, they can’t help but admit that there’s no part of “protecting women like delicate flowers” that involves groping, making lewd and bullying comments, or forcing yourself on women.

That also suggests that if conservatives do find some way to derail the #MeToo movement — which, unlike women themselves, is indeed a delicate flower that could easily be destroyed — they are going to take it.

Leonie’s Facebook post — which, in what I’m sure was a great coincidence, was posted about 40 minutes after the bars close in Austin, Texas — captures that grasping desire to come up with some reason, any reason, to tell all those women to sit down and shut up already about how they don’t like being sexually harassed and abused. It’s a Federalist piece by D.C. McAllister, who dumps a few thousand words attacking a straw man, by arguing, without a shred of evidence, that feminists are opposed to consensual flirting.

“Here’s a little secret we have to say out loud,” she writes. “Women love the sexual interplay they experience with men, and they relish men desiring their beauty.”

(I’m convinced every Federalist writer is out to personally dial down the amount of sex people are having, by the power of their overwrought prose alone. Those two sentences are like a pair of twin beds, but in writing.)

There’s a desperation here, both from McAllister in trying to air out this tedious “feminists are prudes” argument and from Leonie, posting it at the 2:40 a.m. Absolutely no one believes that women who encounter powerful men masturbating at them, groping them, or locking them in rooms are flattered by the attention.

These old arguments and strategies aren’t working, which shows the power that stories have to disrupt false stereotypes and narratives. But if there’s one thing the past couple years have shown, it’s that reactionaries are surprisingly flexible about their strategies. And they’re experimenting, tossing out new ideas about how to end #MeToo.

The first shot, of course, was outing Sen. Al Franken as a serial groper, in an effort to create the narrative that everyone does it so no one should be held accountable. That failed, because Democrats finally saw through it and pushed Franken out. The second attempt was to deliberately make false accusations, with James O’Keefe trying to sell a false accusation against Roy Moore and someone, likely Mike Cernovich, falsifying a document accusing Sen. Chuck Schumer of harassment. The obvious idea there is that by getting some fake accusations into the bloodstream, they can “prove” that fake accusations are all around us and cast doubt on the real ones. Luckily, that failed.

But all this shows that conservatives aren’t going to concede this without a massive fight. Conservatives grasp, even if many liberals don’t, that we’re on the verge of a true social breakthrough. People are beginning to realize it’s not enough to kick a few gross men out, but that this is a systemic problem, that women really are disempowered, that men really do have unfair advantages, and that something really needs to happen to change that.

All of these incidents demonstrate, in other words, that the widespread opinion on the right is that #MeToo is a menace, that it needs to be ended and that the only question right now is how to do it. Their first efforts have failed, but mark my words: They’re going to keep trying. They have money and numbers to keep coming up with random ideas and testing them on the public. It’s just a matter of time until they find a strategy that sticks.

 

 

 

Related Stories

  • Tamara Holder Shares Horrifying Details of Workplace Sexual Assault at Fox News
  • Former Fox News Analyst Tamara Holder Shares Horrifying Details of Sexual Assault
  • The Fempire Strikes Back with #MeToo

Invisible Flying Wizards

In one of my campaigns in one future session the group will come upon a castle. The gates are locked, there are guards on the battlements. Thus there is a challenge to the group to overcome: How do they get into the castle? Now this sounds like classic situation for Dungeons & Dragons. However through most of the history of D&D this was more of a headache for DMs if their group was at least level 5: Wizards had spells like Fly and Invisibility, and that made “sneaking into the castle to open the back door” boring instead of a challenge. So why would I put it in one of my adventures? Because 5th edition cleverly solved the invisible flying wizard problem!

Many of the spells in 5th edition are now using concentration, a new concept. If you want to fly, you can cast the Fly spell, but you will need to concentrate on it. Not only does that mean that if you are hit by an arrow, you have to do a concentration check or fall to the ground; it also means that you can only concentrate on one spell at once. Flying, yes, invisibility, yes, but not both at the same time. Thus the Rogue, who *can* be simultaneously stealthy and climbing walls, isn’t put out of a job by the invisible flying Wizard any more.

Having said that, for some classes the concentration concept is overused and ends up making their spellcasting overly weak. A prime example is the paladin, who has very few non-concentration spells, at least at lower to mid-level. Spells like the level 1 smites really shouldn’t be concentration, as they are already not very powerful and concentration means they don’t work with more important spells like Bless or Compelled Duel. For the Warlock the fact that Hex is a concentration spell and the very staple of his existence, makes any other concentration spell nearly useless.

So, yes, concentration is a useful new concept. But I think it is currently applied to too many spells and could be better balanced.

Creating our own factory method in Java

Creating our own factory method in Java

Any factory method is created as a method belonging to an interface or abstract class. Hence that method is implemented, in the implementation classes or sub classes as case may be.

What are factory methods ?

A factory method is a method that creates and returns an object to the class to which it belongs. A single factory  method replaces several constructors in the class by accepting different options from the user , while creating the object.

For example, to create a factory method getFees() that will give the fees details for a course in an engineering college, we need to perform the following steps :

1> create an interface or abstract class
interface Fees {
   double showFees();
}

2>  Implement the abstract , public methods of the above interface.
class CSE implements Fees {
public double showFees(){
return 120000; // assumed some constant figure
}
}
// their can be more implementation classes also.

3> Create a factory class that contains factory method by the name getFees(). Mostly factory methods are written as static methods.
class CourseFees{
public static Fees getFees(String course){
if(course.equalsIgnoreCase(“CSE”))
return new CSE();
else if(course.equalsIgnoreCase(“ECE”))
return new ECE();
else return null;
}
}

// getFees() method takes the coursename from the user and creates an object either to CSE class or ECE class depending on the user option.

4> Call the factory method like this :
Fees f = CourseFees.getFees(name);

// In the preceding code, an object of CSE class or ECE class is returned by getFees() method. Since CSE and ECE are the implementation classes of Fees interface, we can use Fees interface reference ‘f’  to refer to the objects of these classes. Hence, if we call f.showFees(), then the showFees() of that particular class either CSE or ECE will be executed and corresponding fees will be displayed.

// complete program : combining all 4 steps as above
import java.io.*;

interface Fees {
   double showFees();
}

class CSE implements Fees {
public double showFees(){
return 120000; // assumed some constant figure
}
}

class ECE implements Fees {
public double showFees(){
return 110000; // assumed some constant figure
}
}

class CourseFees{
public static Fees getFees(String course){
if(course.equalsIgnoreCase(“CSE”))
return new CSE();
else if(course.equalsIgnoreCase(“ECE”))
return new ECE();
else return null;
}
}

// using factory method
class Sctpl {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter course name”);
String name = br.readLine();
Fees f = CourseFees.getFees(name);
System.out.println(“The fees is Rs “+ f.showFees());
}
}

USDA Gives in to Big ‘Organic’ Poultry, Moves to Withdraw New Animal Welfare Rules

The Obama-era rules were meant to establish stronger, more enforceable animal welfare requirements for certified organic producers.

On Monday, the U.S. Department of Agriculture (USDA) formally proposed withdrawing a set of rules finalized at the end of the Obama administration that establish stronger, more enforceable animal welfare requirements for certified organic producers.

The rules, titled the Organic Livestock and Poultry Practices rule, are the product of more than a decade of collaboration and coordination among the organic community, including consumers, farmers, veterinarians, environmentalists and animal welfare groups. Unfortunately, a few large-scale egg producers fear the new rules will expose their less-than-organic practices and put pressure on USDA and Congress to stop the rule.

“The new rules are vital for protecting animal welfare, organic consumers, and the thousands of farmers that opt-in to organic certification,” said Cameron Harsh, senior manager for Organic & Animal Policy at the Center for Food Safety.

The rules, which have been delayed from implementation three separate times since being finalized in January 2017, provide needed clarity on organic animal care, including prohibiting several painful alterations. In particular, the rules require all animals to have real access to the outdoors, which must include contact with soil and vegetation, and outline minimum spacing requirements for poultry. This is, in fact, what consumers already expect from the organic poultry and eggs they buy in stores. But the largest poultry producers have so far been able to consider small, cement, fenced-in areas as outdoor access and have not been required to abide by specific spacing limitations.

“The rules would hold all certified producers to the high standard of animal care that consumers expect and that the drafters of the organic law intended. If they are withdrawn, the steadily growing organic market and consumer trust in the organic seal will be at risk,” added Harsh.

Center for Food Safety has submitted extensive comments in support of the rules. While the rules are not perfect, they are a substantial step toward ensuring all organic animals are provided a consistent level of care. The small but vocal opposition against the rules have misrepresented the realities of the rules in order to continue business-as-usual.

The proposal to withdraw the Organic Livestock and Poultry Practices rule is open for public comment until Jan. 17, 2018.

 

 

Related Stories

  • Trump’s USDA Just Made School Meals Less Nutritious
  • Here Are the Top 5 Foods Killing the Planet
  • Dairy Is Bad for Humans, Cows and the Planet: So Why Are Public Schools Required to Offer Milk With Every Meal?