JSP / JSTL :: Trim Whitespace Directive?
Jun 12, 2014
When using trim-directive-whitespaces in a Tomcat 7 application this expression also get trimmed:
<div class="${item.view} ${item.className}">
resulting in the HTML
<div class="personchild">
instead of
<div class="person child">
On the other hand, when I first assign the expression to a varibale it's fine:
<c:set var="className" value="${item.view} ${item.className}"/>
<div class="${className}">
results in the desired HTML
<div class="person child">
Is this the intention of the trim whitespace directive or does this look like a bug?
View Replies
ADVERTISEMENT
Mar 17, 2014
I have the below code with spaces on uri and prefix (directive attribute).
<%@ taglib uri=" news.tld" prefix=" news" %>
how to fix without altering the JSP? Can i handle with web.xml or any other property available.
I have hundreds of jsp like this and wanted to handle without code fixes.
I tried JSP trimSpaces but it fixes the namespace but not the attributes.
View Replies
View Related
Mar 25, 2015
For some reason the following code is not removing whitespace from my string:
temp = sb.toString().trim().replace("s+", " ");
I have printed the string before and after the implementation of the methods above and there is not change in the whitespace of the string.
View Replies
View Related
Sep 21, 2014
<jsp:directive.include file='<%= session.getAttribute("htmlPath").toString(); %>' / I tried to add a Scriptlet in a jsp directive like above. But am keep getting the below error.
HTTP Status 500 - /parseXML.jsp (line: 86, column: 1) File "<%= session.getAttribute("htmlPath").toString(); %>" not found
type Exception report message /parseXML.jsp (line: 86, column: 1) File "<%= session.getAttribute("htmlPath").toString(); %>" not found description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /parseXML.jsp (line: 86, column: 1) File "<%= session.getAttribute("htmlPath").toString(); %>" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:133)
org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:322)
org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:357)
org.apache.jasper.compiler.Parser.parseXMLDirective(Parser.java:533)
org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1764)
org.apache.jasper.compiler.Parser.parse(Parser.java:135)
[code]....
View Replies
View Related
Jan 17, 2015
I used the string split method in the following lines of code like this:
String[] numbers = out.split("[^d.]", 0);
String[] operations = out.split("[.d()]", 0);
When out is equal to the String "2x2.5", the array operations ends up looking like this when it is printed using the toString method:
[, , , x]
As you can see, before the array element x, there are three String variables which only contain whitespace. Why does this occur, and how can I prevent this from happening?
View Replies
View Related
Feb 1, 2015
I have a question about an exercise of OraclePress.
public class OompahLoompah {
public static void main(String[] ar){
final StringBuilder str = new StringBuilder("I good! ");
str.insert(2, "look ").append("and nice");
str.insert(str.length(), "!!!");
str.delete(str.length() - 2, str.length());
System.out.println(str.toString().trim());
}
}
The correct output is "I look good! and nice!" , but i don't understand for what .
Why the trim () method does not work? Whether is working on an object String.
View Replies
View Related
Feb 4, 2014
How can i make sure that when user enter value there is no space between words example :
NEW YORK MUST BE NEW YORK
View Replies
View Related
Feb 4, 2015
I have an array made that represents digits and I am trying to make a method so that if there are zeros in front of the first significant digit I want to trim them, I understand you can't re size arrays so I have created a new array, but my code doesn't seem to run correctly? Here is my code I can't figure out what is wrong I've tried everything: (I put stars around the error**)
package music;
import java.util.Random;
public class Music {
private int length; // length of the array
private int numOfDigits; // number of actual digits in the array
int[] musicArray;
[Code] .......
View Replies
View Related
Jun 10, 2014
I got situation where i have postal code as 0009 in database and the use is entering 0009 but somehow in my java code it only reading 9 from the xml file
This is how i define getter and setter :
When I debug the code i get this :
passed postalcode 9
if a user entered 0009 I what it to remain 0009
Java Code:
public String Postalcode="";
public void setPostalcode(String Postalcode) { this.Postalcode = Postalcode; }
public String getPostalcode() { return Postalcode; }
View Replies
View Related
Oct 6, 2014
In Oracle SQL, when you do trim(column_name), if column_name is blank spaces only (say datatype is CHAR(8)), then "trim(column_name) is null" is true.
In JPQL, if you do "TRIM ( BOTH FROM p.column_name ) is null", does it evaluate to true just like in Oracle SQL?
The reason I'm asking, is my colleague wrote some code in JPQL like below:
... TRIM ( BOTH FROM CONCAT(p.column_name, '#@') ) = '#@'
He said he originally wanted to compare the TRIM result to empty String '', but the result is false, so he concat the column to some junk.
So if after the TRIM, the result is the same junk he added, then the column contains only blanks. I think this works but there could a simpler way to do it.
View Replies
View Related
Feb 26, 2014
May be I did not understand the meaning and usage of attribute "session" in page directive. My understanding is if session=false, in page directive, then the JSP page will not participate in the session. However, I have my welcomepage as below:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
........
.......
<%= session %>
<c:out value="${pageContext.request.session}"/>
if I choose session=true, then both ways of accessing session works , which means the JSP page participated in the session.
But if I change the session=false, then <%= session %> fails, but <c:out value="${pageContext.request.session}"/> does not fail.
how can c:out still show the session, when session = false
View Replies
View Related
Mar 12, 2014
I am fetching records from result set and displaying on JSP with <c:forEach> tag
<c:forEach var="outer" items='${ProductList}' varStatus="seq1">
<tr>
<td class='center' nowrap><input type="radio" name="view" id = "view" value="Y" ></td>
<td class='left' nowrap><c:out value='${outer.sourceIndex}' /></td>
<td class='left' nowrap><c:out value='${outer.prodNameAbbr}' /></td>
<td class='left' nowrap><c:out value='${outer.productName}' /></td>
<td class='left' nowrap><c:out value='${outer.effectiveDate}' /></td>
<td class='left' nowrap><c:out value='${outer.uuName}' /></td>
</tr>
</c:forEach>
Below is one row with radio button
SourceIndex ProductAbbreviation Product Name Effective Date UseID
ABC PQR Test123 03/12/2014 smj
I have a view button also to select above radio button. When I select that I need all above values to be set in request.
View Replies
View Related
May 25, 2014
translate this part to jstl and el?
<%
while(i<nrows){
if(i==0){
%>
<tr>
<td ><b>id_article</b></td>
<td ><b><font color="#FF0033">nbr_stock</font></b></td>
<td ><b>critical_nbr</b></td>
<td ><b><font color="#FF0033">date_first_stock</font></b></td>
[code]....
View Replies
View Related
Sep 9, 2014
I am looking at JSP page, which has code line as follows
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
This taglib will have to be installed on local environment. How is it referred in jsp ? I dont see any code in jsp, which refers to the location of JSTL. So how does jsp invoke these tags ? Is it through classpath ?If its so , how is classpath set for JSTL ? Is it just as classpath is set for java ?
View Replies
View Related
Jun 21, 2006
i am doing a code using JSTL to fire a query. everything come fine except the resule is not sorted as desired. i am putting the code below--
String sort_order=(String)request.getAttribute("sort_order");
request.setAttribute("sort_order",sort_order);
<sql:query var="viewQueryj" sql= "select USER_ID, PERMISSION_ID, USER_NAME from administrator order by ?">
<sql:param value="${sort_order}"/>
</sql:query>
now the resule is always sorted by USER_ID. if i want to sort it using USER_NAME i pass parameter from controller to this page in sort_oredr variable which comes fine but the result doesn't sort by name, only by id. if i hardcode USER_NAME in query then the result is as desired.
View Replies
View Related
Aug 29, 2014
I want to use the list element inside my scriptlet. Below is my code which is not working.
<c:forEach var="social" items="${sociallist}">
<%
callToFunction(%>${social}<%);
%>
</c:forEach>
How can i access social var inside scriptlet.
View Replies
View Related
Jul 31, 2014
In JSP page: firstly set the setter of a entity in bean and then set it in session,request etc. and gvet values using foreach loop as follow :
<jsp:useBean id="st" class="beans.student">
<jsp:setProperty name="st" property="roll_no"/>
</jsp:useBean>
<%
[Code]....
Here start is the variable whose value will vary after every time i visit this function.So how would i be able to use above query.
P.S. i was using scriplet before and i was able to deal these issues with scriplet easily.
View Replies
View Related
Jan 25, 2014
I have the following data in a file called books.xml in my WEB-INF folder:
<?xml version="1.0"?>
<books>
<book>
<name>Padam History</name>
[Code] ....
I'm using the following code in a jsp:
<c:import var="bookInfo" url="/WEB-INF/books.xml" />
I know that it's finding the file because if I delete books.xml from the WEB-INF folder I get a FileNotFound exception.
However, for some reason it doesn't appear to be importing the data into the bookInfo variable.
I noticed this problem because when I try to parse it via:
<x:parse xml="${bookInfo}" var="output"/>
I get org.xml.sax.SAXParseException: Premature end of file.
When I try to display the data in the variable either by:
<c:out value="${bookInfo}" />
...or by means of a scriptlet (which I realize is not a best practice):
<%
String myVariable = (String)pageContext.getAttribute("bookInfo");
System.out.print("bookInfo=" + myVariable);
%>
...I get nothing.
BTW when I do:
<c:import var="data" url="http://www.tutorialspoint.com"/>
<c:out value="${data}"/>
that works fine!
View Replies
View Related
Aug 18, 2014
I have a HashMap returned from the server. There are two conditions
1. HashMap returned with only one set of key value pair or
2. HashMap with multiple set of data key value pairs.
Now in UI I have to display either text box or drop down box depending upon the size of map for that I am using length method
Java Code:
<c:choose>
<c:when test="${fn:length(myDto.mayMapInDto) eq 1}">
display text box
</c:when>
<c:otherwise>
display drop box
</c:otherwise>
</c:choose> mh_sh_highlight_all('java');
I can display drop box by looping but not sure how I can get only one element for text box. Tricky is I can't use key value to access since UI don't know what key will be returned.
View Replies
View Related
Mar 14, 2014
I have for values in drop down:
<SELECT name = "productCodeDefault" id="productCodeDefault" value="<c:out value ='${ProductDefBean.productCodeDefault}'/>" >
<OPTION value="" ></OPTION>
<OPTION value="a" >A1</OPTION>
<OPTION value="b" >B1</OPTION>
<OPTION value="c" >C1</OPTION>
<OPTION value="d" >D1</OPTION>
</SELECT>
When I am getting value = "a" from ProductDefBean, In the dropdown 'A1' should get selected. This is not happening. What I need to modify?
Note** When I am doing view Source of my JSP, I am getting value='a'
View Replies
View Related
Sep 13, 2012
Is there a way we can open a .chm file stored at server through jsp application without downloading the file and saving it to the local machine.
What I googled is : we cannot download .chm files from a web browser and simply click Open. Download the .chm file to your computer first, right-mouse click it in Windows Explorer and select Properties. Then click Unblock.
But I want my users to simply view the file without downloading it.
View Replies
View Related
Nov 12, 2013
In jsp when using EL the parenthesis are not allowed for grouping of expressions. I mean
${(2+3)-1}
is not allowed so if i have to group expressions in EL how do i achieve it?
I wanted to do the following in EL
${(a==b && b==c) || (v==r && r==d)}
so how do i achieve this?
View Replies
View Related
Feb 15, 2013
Why will this NOT validate correctly in my IF Statement? Basically, a user chooses an option from the drop down list. The value is passed to t.jsp (itself) and if the option "All" is chosen, then it does something. If any of the years are chosen, then it does something else.
t.jsp (simplified version of what I want)
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<form method="get" action="t.jsp">
Select Year:
[Code] ....
View Replies
View Related
Mar 7, 2015
I have a variable <c:set var="var1" value = "myvalue" /> , I want to pass var1 as <%= new customclass().method1(var1) %>.what is the syntax to pass this value.
View Replies
View Related
Feb 17, 2015
I am having problem in converting JSTL variable into integer type in JSP (not using Spring). I am looking to do something like below:
<c:set var="total_amt">${list.totalAmount}</c:set>
<c:when test="${new Integer(total_amt) > 500}">
View Replies
View Related
Jul 14, 2014
How to format this "2014-07-14T19:40:46" date to dd-mm-yyyy with time using jstl?
View Replies
View Related