How to link css - vraptor

I am new to web design and am having some problems , one of them (which is killing me ) is that I can not link the css my JSP page . My problem is " simple " : 404 NOT FOUND in the css file.
Actually I got the code below :
< % # include file = " ../../ css / bootstrap.min.css " % > < / style>
However , the q I understand , this is a code that means " brute force " pq copy all css to the HTML page .
I've tried the following methods :
- < Link href = " $ { } pageContext.request.contextPath /css/teste.css " rel = "stylesheet " type = "text / css " >
- < % # Taglib prefix = " fmt " uri = " http://java.sun.com/jsp/jstl/fmt " % >
< % # Taglib prefix = " c " uri = " http://java.sun.com/jsp/jstl/core " % >
...
<link href = " < c : url value = " / css / teste.css " / > " rel = "stylesheet " >

Create a folder inside webapps and call it resource you create folders for your css , js or images .
To use, simply do:
<link rel="stylesheet" href="<c:url value="/resources/css/yourfile.css"/>">

Related

Getting image from an online XML file or a URL in xamarin forms

I am unable to get image from a URL that is an XML response. i used following code to fetch information from this URL including image too since i thought that i will get image although the xml response has image url but i am getting image URL instead of image.
Why is it so? kindly guide me! i am a newbie to xamarin forms.
URl : https://www.goodreads.com/book/title.xml?key=Uxb0zPb86N4STVy2ECWYA&title=Dune
CODE:
XElement search_result =(from xFi in Xdoc.Descendants("book")
where (xFi.Element("country_code").Value == "PK") || (xFi.Element("language_code").Value == "eng")
select xFi).FirstOrDefault();
if (search_result != null)
{ search.Text=
"Title: " + search_result.Element("title").Value + "\n" +
"Average Ratings: " + search_result.Element("average_rating").Value + "\n" +
"ISBN: " + search_result.Element("isbn").Value + "\n" +
"PUBLICATION YEAR: " + search_result.Element("publication_year").Value +
"\n" +"PUBLISHER: " + search_result.Element("publisher").Value + "\n" +
"DESCRIPTION: " + "\n" + search_result.Element("description").Value + "\n"
+ "IMAGE: " + "\n" + search_result.Element("image_url").Value + "\n";
} else
{
search.Text = "Found Nothing";
}
assuming I have an Image control on my page named "bookimage"
var url = search_result.Element("image_url").Value;
bookimage.Source = ImageSource.FromUri(new Uri(url));
this is clearly explained in the docs

.NET Replace() doesn´t work

Hi i´m parsing aspx file to XML and i have this code:
if (lineLower.StartsWith("</asp:content>")) || (lineLower.StartsWith("</asp:Content>") && lineLower.EndsWith(">")))
{
temp += line.Replace(line, " ");
}
But this temp += line.Replace(line, " "); will just add a space before < /asp:content> instead of replacing it byt space.
Do i need to use different syntax?
First, you have this
if (lineLower.StartsWith("</asp:content>"))
You're closing your if too soon
Try this
if (lineLower.StartsWith("</asp:content>") || (lineLower.StartsWith("</asp:Content>") && lineLower.EndsWith(">"))
{
temp += line.Replace(line, " ");
}
You coded it way too complicated
Just do this:
if (line.ToLower().StartsWith("</asp:content>") && line.EndsWith(">")))
{
temp += " ";
}
Not even sure if you need this part : line.EndsWith(">")

How to find which properties in the .theme file are used to generate a given CSS class in GXT3?

Current Sencha documentation about their Theme Builder is very limited, it covers only the file basic structure and the syntax (including gradients and functions):
http://docs.sencha.com/gxt/3.1/ui/theme/syntax/ThemeBuilderSyntax.html
My problem is which property should I set in the .theme file in order to affect an specific CSS class? For example the font used in the header of a ContentPanel.
First thing I tried was to have a look in the file themebuilder\examples\skeleton-config\skeleton-config.theme which is supposed to have "all required properties", but I could not find any "contentPanel" in it.
This is the example they have in the documentation:
details {
info {
messageText = defaultFont
//note that this could also be written as
//messageText = theme.defaultFont
}
}
In this case it is straightforward because there is an Info class which matches the "info" element used in the theme.
Then I had a look in the generated HTML and found this CSS class name in the header of my ContentPanel:
.CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText
By looking at this class name I thought the element name to be used in the .theme file would be "panel" and the property name would be "headerText", but unfortunately checking the file skeleton-config.theme I saw there is no headerText property in the panel element.
I have found headerText in other elements like datePicker, errortip, info and tip, so it is funny that panel does not have it.
The way I have found to know exactly which configuration parameter I have to set in order to affect an specific CSS was to have a look at the GWT generated classes.
I started by checking the generated HTML and there I found the CSS class name:
.CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText
Then I searched for this string in the directory target/.generated (I am using Maven) and found the class Css3HeaderAppearance_Css3HeaderResources_default_InlineClientBundleGenerator.java where that string appeared many times:
".CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText {\n right : " + ("20px") + ";\n}\n" +
".CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText {\n font-family : " + ("tahoma"+ ","+ " " +"arial"+ ","+ " " +"verdana"+ ","+ " " +"sans-serif") + ";\n font-size : " + ("11px") + ";\n font-weight : " + ("bold") + ";\n line-height : " + ("15px") + ";\n color : ") + ((theme().panel().font().color() + "") + ";\n font-size : " + (theme().panel().font().size() + "") + ";\n font-weight : " + (theme().panel().font().weight() + "") + ";\n font-family : " + (theme().panel().font().family() + "") + ";\n line-height : " + ("15px") + ";\n text-transform : " + ("none") + ";\n}\n.PR-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerBar {\n float : " + ("left") + ";\n}\n/* CssDef */\n/* CssDef */\n/* CssDef */\n/* CssDef */\n")) : ((".OR-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-header {\n padding : " + ("4px"+ " " +"3px"+ " " +"2px"+ " " +"5px") + ";\n position : " + ("relative") + ";\n padding : " + ("0") + ";\n}\n.BS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerIcon {\n float : " + ("left") + ";\n}\n.AS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerHasIcon .BS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerIcon {\n width : " + ("18px") + ";\n}\n.AS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerHasIcon " +
".CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText {\n left : " + ("20px") + ";\n}\n" +
".CS-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerText {\n font-family : " + ("tahoma"+ ","+ " " +"arial"+ ","+ " " +"verdana"+ ","+ " " +
"sans-serif") + ";\n font-size : " + ("11px") + ";\n font-weight : " + ("bold") + ";\n line-height : " + ("15px") +
";\n color : ") + ((theme().panel().font().color() + "") + ";\n font-size : " + (theme().panel().font().size() + "") + ";\n " +
"font-weight : " + (theme().panel().font().weight() + "") + ";\n font-family : " + (theme().panel().font().family() + "") + ";\n line-height : " + ("15px") + ";\n text-transform : " + ("none") + ";\n}\n.PR-com-example-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerBar {\n float : " + ("right") + ";\n}\n/* CssDef */\n/* CssDef */\n/* CssDef */\n/* CssDef */\n"));
I have noticed that it first generates some hard-coded CSS classes and at the end it generated a CSS class based on the values returned by calls to theme().*.
Finally, by comparing these calls with the structure of the file skeleton-config.theme I had the answer to my question:
theme() maps to the "details" element in the .theme file
theme().panel() maps to details.panel or
details {
panel {
so the configuration I had to use was the font property inside the panel element.
This answers my first question, but it does not clarify what are all widgets affected by the "panel" element in the .theme file.

How can I use XQuery using a for loop inside another for loop?

When parsing any XML like below, in order to fetch the PATH/TEST_PATH and ALIAS,
<TEST TEST_VERSION="14">
<TEST_QUERY_LIST PROP="0">
<TEST_QUERY_FILE>"C:/Files/File.txt"</TEST_QUERY_FILE>
</TEST_QUERY_LIST>
<TEST_OUTPUT>
<FILE PATH="C:/Files/File2.txt" TEST_TYPE_ID_REF="1">
<USED_BY TEST_PATH="C:/Files/File2.txt" ALIAS="thisData"/>
<USED_BY TEST_PATH="C:/Files/File3.txt" ALIAS="thatData"/>
</FILE>
<FILE PATH="C:/Files/File1.txt" TEST_TYPE_ID_REF="1">
<USED_BY TEST_PATH="C:/Files/File5.txt" ALIAS="Data"/>
</FILE>
</TEST_OUTPUT>
</TEST>
I write a query like
.....setQuery(
"for $x in doc($xmlByteArry)//TEST/TEST_OUTPUT/FILE"
" return if($x/#TEST_TYPE_ID_REF = 1) "
" then ($x/USED_BY/#TEST_PATH, $x/USED_BY/#ALIAS, $x/#PATH ) "
" else ()");
But the problem is that the output is random, ie: I can not associate the outputs into a relation.
I would be happy to get the output where PATH, TEST_PATH and ALIAS are related
Something like ::
"C:/Files/File2.txt", "C:/Files/File2.txt", "thisData"
"C:/Files/File2.txt", "C:/Files/File3.txt", "thatData"
"C:/Files/File1.txt", "C:/Files/File5.txt", "Data"
After some thought I try to modify it like this
.....setQuery(
"for $x in doc($xmlByteArry)//TEST/TEST_OUTPUT/FILE"
" for $y in $x/USED_BY "
" return if($x/#TEST_TYPE_ID_REF = 1) "
" then concat ($y/#TEST_PATH, ':::', $y/#ALIAS, ':::', $x/#PATH ) "
" else ()");
I get an exception when this query is evaluated. Any hint why it fails to recognize the XML ? I use the following code (C++/Qt)
QString getParsedString()
{
QByteArray xmlByteArry;
QBuffer device(&xmlByteArry);
device.setData(XmlTree().toUtf8());
device.open(QIODevice::ReadOnly);
QXmlQuery query;
query.bindVariable("xmlByteArry", &device);
// query.setQuery("for $x in doc($xmlByteArry)//TEST/TEST_OUTPUT/FILE"
// " return if($x/#TEST_TYPE_ID_REF = 1) "
// " then ($x/USED_BY/#TEST_PATH,':::',$x/USED_BY/#ALIAS,':::',$x/#PATH) "
// " else ()");
query.setQuery("for $x in doc($xmlByteArry)//TEST/TEST_OUTPUT/FILE"
" for $y in $x/USED_BY "
" return if($x/#TEST_TYPE_ID_REF = 1) "
" then concat($y/#TEST_PATH,':::',$y/#ALIAS,':::',$x/#PATH)"
" else ()");
QString values;
if(query.isValid())
{
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem XmlItem(result.next());
while (!XmlItem.isNull())
{
//Code to parse the Internal ones
if(XmlItem.isAtomicValue())
{
//I hope some values will be atomic like ALIAS and TEST_PATH
values.append(XmlItem.toAtomicValue().toString());
}
else if (XmlItem.isNode())
{
//I hope to get the FILE Node and USED_BY node but I dont see anything in the following stringValue.
QXmlNodeModelIndex Index = XmlItem.toNodeModelIndex();
values.append(Index.stringValue());
}
XmlItem = result.next();
}
}
return values;
}

How do I detect what browser is used to access my site?

How do I detect what browser (IE, Firefox, Opera) the user is accessing my site with? Examples in Javascript, PHP, ASP, Python, JSP, and any others you can think of would be helpful. Is there a language agnostic way to get this information?
If it's for handling the request, look at the User-Agent header on the incoming request.
UPDATE: If it's for reporting, configure your web server to log the User-Agent in the access logs, then run a log analysis tool, e.g., AWStats.
UPDATE 2: FYI, it's usually (not always, usually) a bad idea to change the way you're handling a request based on the User-Agent.
Comprehensive list of User Agent Strings from various Browsers
The list is really large :)
You would take a look at the User-Agent that they are sending. Note that you can send whatever agent you want, so that's not 100% foolproof, but most people don't change it unless there's a specific reason to.
A quick and dirty java servlet example
private String getBrowserName(HttpServletRequest request) {
// get the user Agent from request header
String userAgent = request.getHeader(Constants.BROWSER_USER_AGENT);
String BrowesrName = "";
//check for Internet Explorer
if (userAgent.indexOf("MSIE") > -1) {
BrowesrName = Constants.BROWSER_NAME_IE;
} else if (userAgent.indexOf(Constants.BROWSER_NAME_FIREFOX) > -1) {
BrowesrName = Constants.BROWSER_NAME_MOZILLA_FIREFOX;
} else if (userAgent.indexOf(Constants.BROWSER_NAME_OPERA) > -1) {
BrowesrName = Constants.BROWSER_NAME_OPERA;
} else if (userAgent.indexOf(Constants.BROWSER_NAME_SAFARI) > -1) {
BrowesrName = Constants.BROWSER_NAME_SAFARI;
} else if (userAgent.indexOf(Constants.BROWSER_NAME_NETSCAPE) > -1) {
BrowesrName = Constants.BROWSER_NAME_NETSCAPE;
} else {
BrowesrName = "Undefined Browser";
}
//return the browser name
return BrowesrName;
}
You can use the HttpBrowserCapabilities Class in ASP.NET. Here is a sample from this link
private void Button1_Click(object sender, System.EventArgs e)
{
HttpBrowserCapabilities bc;
string s;
bc = Request.Browser;
s= "Browser Capabilities" + "\n";
s += "Type = " + bc.Type + "\n";
s += "Name = " + bc.Browser + "\n";
s += "Version = " + bc.Version + "\n";
s += "Major Version = " + bc.MajorVersion + "\n";
s += "Minor Version = " + bc.MinorVersion + "\n";
s += "Platform = " + bc.Platform + "\n";
s += "Is Beta = " + bc.Beta + "\n";
s += "Is Crawler = " + bc.Crawler + "\n";
s += "Is AOL = " + bc.AOL + "\n";
s += "Is Win16 = " + bc.Win16 + "\n";
s += "Is Win32 = " + bc.Win32 + "\n";
s += "Supports Frames = " + bc.Frames + "\n";
s += "Supports Tables = " + bc.Tables + "\n";
s += "Supports Cookies = " + bc.Cookies + "\n";
s += "Supports VB Script = " + bc.VBScript + "\n";
s += "Supports JavaScript = " + bc.JavaScript + "\n";
s += "Supports Java Applets = " + bc.JavaApplets + "\n";
s += "Supports ActiveX Controls = " + bc.ActiveXControls + "\n";
TextBox1.Text = s;
}
PHP's predefined superglobal array $_SERVER contains a key "HTTP_USER_AGENT", which contains the value of the User-Agent header as sent in the HTTP request. Remember that this is user-provided data and is not to be trusted. Few users alter their user-agent string, but it does happen from time to time.
On the client side, you can do this in Javascript using the navigation.userAgent object. Here's a crude example:
if (navigator.userAgent.indexOf("MSIE") > -1)
{
alert("Internet Explorer!");
}
else if (navigator.userAgent.indexOf("Firefox") > -1)
{
alert("Firefox!");
}
A more detailed and comprehensive example can be found here: http://www.quirksmode.org/js/detect.html
Note that if you're doing the browser detection for the sake of Javascript compatibility, it's usually better to simply use object detection or a try/catch block, lest some version you didn't think of slip through the cracks of your script.
For example, instead of doing this...
if(navigator.userAgent.indexOf("MSIE 6") > -1)
{
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
objXMLHttp = new XMLHttpRequest();
}
...this is better:
if(window.XMLHttpRequest) // Works in Firefox, Opera, and Safari, maybe latest IE?
{
objXMLHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) // If the above fails, try the MSIE 6 method
{
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
It may be dependent of your setting. With apache on linux, its written in the access log /var/log/apache2/access_log
You can do this by:
- looking at the web server log, OR
- looking at the User-Agent field in the HTML request (which is a plain text stream) before processing it.
First of all, I'd like to note, that it is best to avoid patching against specific web-browsers, unless as a last result -try to achieve cross-browser compatibility instead using standard-compliant HTML/CSS/JS (yes, javascript does have a common denominator subset, which works across all major browsers).
With that said, the user-agent tag from the HTTP request header contains the client's (claimed) browser. Although this has become a real mess due to people working against specific browser, and not the specification, so determining the real browser can be a little tricky.
Match against this:
contains browser
Firefox -> Firefox
MSIE -> Internet Explorer
Opera -> Opera (one of the few browsers, which don't pretend to be Mozilla :) )
Most of the agents containing the words "bot", or "crawler" are usually bots (so you can omit it from logs / etc)
check out browsecap.ini. The linked site has files for multiple scripting languages. The browsecap not only identifies the user-agent but also has info about the browser's CSS support, JS support, OS, if its a mobile browser etc.
cruise over to this page to see an example of what info the browsecap.ini can tell you about your current browser.

Resources