I am trying to display a image in html in JSP script, just using img tag.
index.jsp code:
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="topbar">
<img src="images/x.png" alt="img" height="30" width="25">
</div>
</body>
</html>
I ma using eclipse neon (apache-tomcat local server in Ubuntu) and my directory structure is :
When I run index.jsp , image is not displayed. What I am doing wrong?
Please ask me if you need more information.
#user3138997 gave me hints:
I just need to write as:
<img src="/projectName/images/x.png" alt="img" height="30" width="25">
And this shows the image.
Related
I am trying to understand why this piece of code never prints the method request when run on tomcat 9:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${\"POST\".equalsIgnoreCase(pageContext.request.method) && pageContext.request.getParameter(\"submit\") != null}">
<%= request.getMethod() %>
</c:if>
<form method="post">
Name: <input type="text" name="name"> <br>
Credits : <input type="text" name="credits"> <br>
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
I don't have Tomcat 9 currently installed on my system, but it runs fine in Tomcat 8.5, and Jetty 9.4.17 printing "POST" whenever I post the form.
However, el language, despite resembling Java in many aspects and being able to call Java functions is NOT actually Java. You will encounter more success and consistency using it in a more idiomatic way. In your case, I'm pretty sure the following will work on any up-to-date JSP server:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${'post' eq fn:toLowerCase(pageContext.request.method) and param.submit ne null}">
${pageContext.request.method}
</c:if>
<form method="post">
Name: <input type="text" name="name" /><br />
Credits: <input type="text" name="credits" /><br />
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
Using the fn taglib to compare strings in lower case
Using single quotes around strings to avoid escaping
Using el eq and ne operators for "equals" and "not equals"
Using el and boolean operator
Using el variable param to access request parameters
Using ${...} syntax to output values rather than scriptlets
On our main intranet page (homepage) http://indi.cdc.com I created a link to InfoPath form that is on a site collection http://indi.cdc.com/salesteam. So the link looks like this. When user click Submit or Cancel they are not redirected back to homepage (http://indi.cdc.com). They are seeing "The form has been closed.). Please suggest.
I tried following and neither is doing the redirection.
http://indi.cdc.com/salesteam/Lists/RequestsList/Issue/newifs.aspx?Source=http://indi.cdc.com/Pages/Home.aspx
http://indi.cdc.com/salesteam/Lists/RequestsList/Issue/newifs.aspx?Source=http://indi.cdc.com/Pages/Home.aspx?target=http://indi.cdc.com/salesteam
Created a redirect page (http://indi.cdc.com/salesteam/SharedDocuments/Redirecting.html)
Created a view on the target list where the InfoPath form is redirect.aspx, edit the page and dropped a CEWP and reference above html file from it. (http://indi.cdc.com/salesteam/spteam/Lists/RequestsList/redirect.aspx)
Recreated the link on the homepage.
http://indi.cdc.com/salesteam/spteam/Lists/RequestsList/Issue/newifs.aspx?Source=http://indi.cdc.com/salesteam/Lists/RequestsList/redirecting.aspx
Here is the html code for redirecting.html page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Refresh"
content="0; URL=http://indi.cdc.com">
<title></title>
</head>
<body>
</body>
</html>
As far as I understood, we needed to use styleClass= as the JSF components don't support using just class=.
I've noticed recently that some components that were using class= were still rendering correctly. As a minimal example,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
<h:inputText class="wut" anothertag="hi" value="me"/>
</h:body>
</html>
This produces
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/individuallifefaz/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo"/>
<title>Simple JSF Facelets page</title></head>
<body>
<input type="text" name="j_idt5" value="me" class="wut"/>
</body>
</html>
Why is this working? It's clearly not just passing through any unknown tags, as the anothertag is stripped out.
This is actually done by the view technology Facelets, not by the JSF component itself. Facelets has an alias for class attribute which automatically maps to styleClass. This was implemented as part of support for jsfc attribute as used in "designer friendly Facelets" which should make things like this possible:
<input type="text" jsfc="h:inputText" class="foo" />
If you use JSF with a different view technology (although so far there's none which is a serious alternative to Facelets, and JSP is deprecated), then there's no guarantee that <h:inputText class> would work.
See also:
Is there a way to run a JSF page without building the whole project?
I would be grateful if someone could clarify if this document is valid for xhtml parsing using the iphone SDK using xpaths:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>East Lancs Radio - Now Playing</title>
<META HTTP-EQUIV="REFRESH" CONTENT="45">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div id="player-currently-playing">
Currently Playing
<div class="player-track">
Lush
</div>
<div class="player-artist">
Ladykillers
</div>
</div>
<div id="player-playing-next">
Playing Next
<div class="player-track">
Javine
</div>
<div class="player-artist">
Surrender (Your...
</div>
</div>
</body>
</html>
I'm trying to extract the currently playing player-track 'lush' and player-artist 'ladykillers' through using xpath. If I do an xpath search for: //#class and then print the result to screen, I get player-track, player-artist.. etc outputted?
Am I missing something fairly obvious here?
Thanks
Dan
The W3C Markup Validation Service comes up with 9 errors in this document.
So, this is not a valid XHTML document, for iPhone usage or otherwise.
Your XPath result is giving you what you're asking for which is the values of the class attributes.
To get the currently playing player-track use:
//*[#id = 'player-currently-playing']/*[#class = 'player-track']/text()
and to get the currently playing player-artist use:
//*[#id = 'player-currently-playing']/*[#class = 'player-artist']/text()
I'm trying to integrate a Like box in my website. It wasn't working, so I created a sample page (which also doesn't work).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FB TEST</title>
</head>
<body>
<iframe src="http://www.facebook.com/plugins/likebox.php?profile_id=185550966885&width=292&connections=5&stream=false&header=true" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:292px; height:px"></iframe>
</body>
</html>
I'm also using the sample iframe code (mine didn't work, so I tried this), taken from:
http://developers.facebook.com/docs/reference/plugins/like-box
The sample page is here:
http://www.plugb.com/fb-test.php
How can I fix this?
Thanks in advance.
There appears to be a bug in the code they generate. If you replace "profile_id" with "id" in the URL they generate it should work.