Introduction to web development _(CS378)_Wednesday, 19 April, 2017 Modify your p
ID: 3705297 • Letter: I
Question
Introduction to web development _(CS378)_Wednesday, 19 April, 2017 Modify your project to hold the following: 1. A servlet that allows the user to customize the page background and foreground colors and keeps these preferences for a week only then returns to the default layout. 2. Login and logout servlets functionality using HttpSession. Assume that the password is "012345". Only users with a valid password can view all the website pages. However, gusts can view certain pages such as About us page or Contact us page form.Explanation / Answer
Photoshop uses the foreground color to paint, fill, and stroke selections and the background color to make gradient fills and fill in the erased areas of an image.
The foreground and background colors are also used by some special effects filters.
You can designate a new foreground or background color using the Eyedropper tool, the Color panel, the Swatches panel, or the Adobe Color Picker.
The default foreground color is black, and the default background color is white.
Choose colors in the toolbox
The current foreground color appears in the upper color selection box in the toolbox; the current background color appears in the lower box.
Foreground and background color boxes in toolbox
A. Default Colors icon B. Switch Colors icon C. Foreground color box D. Background color box
To change the foreground color, click the upper color selection box in the toolbox, and then choose a color in the Adobe Color Picker.
To change the background color, click the lower color selection box in the toolbox, and then choose a color in the Adobe Color Picker.
To reverse the foreground and background colors, click the Switch Colors icon in the toolbox.
To restore the default foreground and background colors, click the Default Colors icon in the toolbox.
Choose colors with the Eyedropper tool
The Eyedropper tool samples color to designate a new foreground or background color. You can sample from the active image or from anywhere else on the screen.
Select the Eyedropper tool .
In the options bar, change the sample size of the eyedropper by choosing an option from the Sample Size menu:
Point Sample
Reads the precise value of the pixel you click.
3 by 3 Average, 5 by 5 Average, 11 by 11 Average, 31 by 31 Average, 51 by 51 Average, 101 by 101 Average
Reads the average value of the specified number of pixels within the area you click.
Photoshop Eyedropper tool
Selecting a foreground color with the Eyedropper tool
Choose one of the following from the Sample menu:
All Layers
Samples color from all layers in the document.
Current Layer
Samples color from the currently active layer.
To circle the Eyedropper tool with a ring that previews the sampled color above the current foreground color, select Show Sampling Ring.
Do one of the following:
To select a new foreground color, click in the image. Alternatively, position the pointer over the image, press the mouse button,
and drag anywhere on the screen. The foreground color selection box changes dynamically as you drag. Release the mouse button to pick the new color.
To select a new background color, Alt-click (Windows) or Option-click (Mac OS) in the image. Alternatively, position the pointer over
the image, press Alt (Windows) or Options (Mac OS), press the mouse button, and drag anywhere on the screen. The background color
selection box changes dynamically as you drag. Release the mouse button to pick the new color.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*).htm$ $1.php [NC]
Handy for anyone updating a site from static htm (you could use .html, or .htm(.*), .html?, etc.) to dynamic php pages; requests to the old pages
are automatically rewritten to our new urls. No one notices a thing, visitors and search engines can access your content either way. Leave the rule in;
as an added bonus, this enables us to easily split php code and its included html structures into two separate files, a nice idea; makes editing and
updating a breeze. The [NC] part at the end means "No Case", or "case-insensitive"; more on the switches, later.
Folks can link to whatever.htm or whatever.php, but they always get whatever.php in their browser, and this works even if whatever.htm doesn't exist!
But I'm straying..
As it stands, it's a bit tricky; folks will still have whatever.htm in their browser address bar, and will still keep bookmarking your old
.htm URL's. Search engines, too, will keep on indexing your links as .htm, some have even argued that serving up the same content from two
different places could have you penalized by the search engines. This may or not bother you, but if it does, mod_rewrite can do some more magic..
this will do a "real" external redirection:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+).htm$ http://corz.org/$1.php
This time we instruct mod_rewrite to do a proper external rewrite, aka, "redirection". Now, instead of just background rewriting on-the-fly, the
user's browser is physically redirected to a new URI, and whatever.php appears in their browser's address bar - search engines and other spidering
entities will automatically update their links to the .php versions; everyone wins. You can take your time with the updating, too.
***if you use [R] alone, it defaults to sending an HTTP "MOVED TEMPORARILY" redirection, aka, "302". But you can send other codes, like so..
this performs the exact same as the previous example RewriteRule.
RewriteRule ^(.+).htm$ http://corz.org/$1.php
Okay, I sent the exact same code, but I didn't have to. For details of the many 30* response codes you can send, see here. Most people probably want to
send 301, aka, "MOVED PERMENENTLY".
Note: if you add an "L" flag to the mix; meaning "Last Rule"; Apache will stop processing rules for this request at that point,
which may or may not be what you want. Either way, it's useful to know.
not-so-simple rewriting ... flat links and more
You may have noticed, the above examples use regular expression to match variables. What that simply means is.. match the part inside (.+) and use
it to construct "$1" in the new URL. In other words, (.+) = $1 you could have multiple (.+) parts and for each, mod_rewrite automatically creates a
matching $1, $2, $3, etc, in your target (aka. 'substitution') URL. This facility enables us to do all sorts of tricks, and the most common of those,
is the creation of "flat links"..
Even a cute short link like http://mysite/grab?file=my.zip is too ugly for some people, and nothing less than a true old-school
solid domain/path/flat/link will do. Fortunately, mod_rewrite makes it easy to convert URLs with query strings and multiple variables into exactly this,
something like..
a more complex rewrite rule:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?section=$1&file=$2 [NC]
would allow you to present this link as..
http://mysite/files/games/hoopy.zip
and in the background have that transparently translated, server-side, to..
http://mysite/download.php?section=games&file=hoopy
which some script could process. You see, many search engines simply don't follow our ?generated=links,
so if you create generating pages, this is useful. However, it's only the dumb search engines that
can't handle these kinds of links; we have to ask ourselves.. do we really want to be listed by the
dumb search engines? Google will handle a good few parameters in your URL without any problems, and
the (hungry hungry) msn-bot stops at nothing to get that page, sometimes again and again and again…
I personally feel it's the search engines that should strive to keep up with modern web technologies,
in other words; we shouldn't have to dumb-down for them. But that's just my opinion. Many users will
prefer /files/games/hoopy.zip to /download.php?section=games&file=hoopy but I don't mind either way.
As someone pointed out to me recently, presenting links as standard/flat/paths means you're less likely
to get folks doing typos in typed URL's, so something like..
an even more complex rewrite rule:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/([0-9]+)-([a-z]+) http://corz.org/blog/index.php?archive=$1-$2
would be a neat trick, enabling anyone to access my blog archives by doing..
http://corz.org/blog/2003-nov
in their browser, and have it automagically transformed server-side into..
http://corz.org/blog/index.php?archive=2003-nov
with a little imagination, and a basic understanding of posix regular expression, you can perform some highly cool URL manipulations.
Here's the basics of regexp (expanded from the Apache mod_rewrite documentation)..
Escaping:
char escape that particular char
For instance to specify special characters.. [].() etc.
Text:
. Any single character (on its own = the entire URI)
[chars] Character class: One of following chars
[^chars] Character class: None of following chars
text1|text2 Alternative: text1 or text2 (i.e. "or")
e.g. [^/] matches any character except /
(foo|bar).html matches foo.html and bar.html
Quantifiers:
? 0 or 1 of the preceding text
* 0 or N of the preceding text (hungry)
+ 1 or N of the preceding text
e.g. (.+).html? matches foo.htm and foo.html
(foo)?bar.html matches bar.html and foobar.html
Grouping:
(text) Grouping of text
Either to set the borders of an alternative or
for making backreferences where the nthe group can
be used on the target of a RewriteRule with $n
e.g. ^(.*).html foo.php?bar=$1
Anchors:
^ Start of line anchor
$ End of line anchor
An anchor explicitly states that the character right next to it MUST
be either the very first character ("^"), or the very last character ("$")
of the URI string to match against the pattern, e.g..
^foo(.*) matches foo and foobar but not eggfoo
(.*)l$ matches fool and cool, but not foo
If you are new to messing around with code or text, you should memorize the above section.
The power you gain and the time you will save is well worth the minutes it will take to get your head around it!
I use regex dozens, sometimes hundreds of times a day, mainly to find specific strings in large documents.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.