JSP/Struts How to get a String to display as HTML?
<logic:present name="ShowAnswers">
<logic:iterate id="ShowAnswers" name="ShowAnswers">
<br>
<html:textarea name="ShowAnswers" property="anAnswer"> </html:textarea>
</logic:iterate>I've got a Vector of Strings that are being written to a .jsp using <logic:iterate> as shown above. The String anAnswer contains HTML code.
Is there a way to get it written using the above framework as HTML rather than text ?
I've tried <bean:write name="ShowAnswers" property="anAnswer"/> which also just writes out the raw HTML rather than the formatted HTML.
try using the "filter" attribute of bean:write.
<bean:write name="ShowAnswers" property="anAnswer" filter="false"/>
For clarity you should use different names for your loop variable and your actual list. I know that it currently works, but thats only because they are in two different scopes.
Also standard coding conventions specify that variable names should always start with a lower case letter.
<logic:present name="ShowAnswers">
<logic:iterate id="anAnswer" name="ShowAnswers">
<br>
<bean:write name="anAnswer" property="anAnswer" filter="false"/>
</logic:iterate>
Similar Messages
-
How to get a string "yyyyMMdd" into date like MM/dd/yyyy?.
Hi
How to get a string "yyyyMMdd" into date like MM/dd/yyyy?. i have used
SimpleDateFormat.parse but it is giving long value. i want to disply the date
like MM/dd/yyyy
thank youDo you want the string rearranged or do you want to create an instance of some form of Date class?
If you want to rearrange the string you could just do it yourself provided you know the date string is going to be of the format yyyyMMdd.
something like this:
String newDate = origStr.charAt(4) + origStr.charAt(5) + "/" + origStr.charAt(6) + origStr.charAt(7) + "/" ...etc. -
How to get alternative strings in list of strings.
Hi experts,
how to get alternative strings in list of strings.
eg
'country1, italy, country2, india, country3, paris, country4, scottland, country5, rome'
from the above list i need to fetch all the countries and their names separately.
like country1, country2, country3, country4, country5
italy, india, paris, scottland, rome
i am trying the above one in the below fashion
SELECT SUBSTR
('country1, italy, country2, india, country3, paris, country4, scottland, country5, rome',
1,
INSTR
('country1, italy, country2, india, country3, paris, country4, scottland, country5, rome',
1,
1
- 1
FROM DUAL
can you please any one help meIf you want the data to be more stuctured, and useful:
col col_name for a20
col col_value for a20
var inlist VARCHAR2(2000)
exec :inlist := 'country1, italy, country2, india, country3, paris, country4, scottland, country5, rome';
exec :inlist := replace(:inlist,' ')
select max(decode(mod(lvl,2),1,value)) col_name
,max(decode(mod(lvl,2),0,value)) col_value
from (select substr(:InList,start_pos+1, end_pos-start_pos-1) value
,lvl
from (select :InList
,case when level = 1 then
0
else
instr(:InList,',',1,level-1)
end start_pos
,case when instr(:InList,',',1,level) = 0
then length(:InList)+1
else
instr(:InList,',',1,level)
end end_pos
,level lvl
from dual
connect by level <=length(:InList)-length(replace(:InList,','))+1
group by ceil(lvl/2)
order by 1;
COL_NAME COL_VALUE
country1 italy
country2 india
country3 paris
country4 scottland
country5 rome
Untested on 10g
Then you could stragg the rows together ... -
How to get the source code of an HTML page in Text file Through J2EE
How to get the source code of an HTML page in Text file Through J2EE?
Huh? If you want something like your browser's "view source" command, simply use a URLConnection and read in the data from the URL in question. If the HTML page is instead locally on your machine, use a FileInputStream. There's no magic invovled either way.
- Saish -
How to get the source code of an HTML page in Text file Through java?
How to get the source code of an HTML page in Text file Through java?
I am coding an application.one module of that application is given below:
The first part of the application is to connect our application to the existing HTML form.
This module would make a connection with the HTML page. The HTML page contains the coding for the Form with various elements. The form may be a simple form with one or two fields or a complex one like the form for registering for a new Bank Account or new email account.
The module will first connect through the HTML page and will fetch the HTML code into a Text File so that the code can be further processed.
Could any body provide coding hint for thatYou're welcome. How about awarding them duke stars?
edit: cheers! -
How to get a string or byte array representation of an Image/BufferedImage?
I have a java.awt.Image object that I want to transfer to a server application (.NET) through a http post request.
To do that I would like to encode the Image to jpeg format and convert it to a string or byte array to be able to send it in a way that the receiver application (.NET) could handle. So, I've tried to do like this.
private void send(Image image) {
int width = image.getWidth(null);
int height = image.getHeight(null);
try {
BufferedImage buffImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
ImageIcon imageIcon = new ImageIcon(image);
ImageObserver observer = imageIcon.getImageObserver();
buffImage.getGraphics().setColor(new Color(255, 255, 255));
buffImage.getGraphics().fillRect(0, 0, width, height);
buffImage.getGraphics().drawImage(imageIcon.getImage(), 0, 0, observer);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(stream);
jpeg.encode(buffImage);
URL url = new URL(/* my url... */);
URLConnection connection = url.openConnection();
String boundary = "--------" + Long.toHexString(System.currentTimeMillis());
connection.setRequestProperty("method", "POST");
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
String output = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"myImage\"; filename=\"myFilename.jpg\"\r\n"
+ "Content-Type: image/jpeg\r\n"
+ "Content-Transfer-Encoding: base64\r\n\r\n"
+ new String(stream.toByteArray())
+ "\r\n--" + boundary + "--\r\n";
connection.setDoOutput(true);
connection.getOutputStream().write(output.getBytes());
connection.connect();
} catch {
}This code works, but the image I get when I save it from the receiver application is distorted. The width and height is correct, but the content and colors are really weird. I tried to set different image types (first line inside the try-block), and this gave me different distorsions, but no image type gave me the correct image.
Maybe I should say that I can display the original Image object on screen correctly.
I also realized that the Image object is an instance of BufferedImage, so I thought I could skip the first six lines inside the try-block, but that doesn't help. This way I don't have to set the image type in the constructor, but the result still is color distorted.
Any ideas on how to get from an Image/BufferedImage to a string or byte array representation of the image in jpeg format?Here you go:
private static void send(BufferedImage image) throws Exception
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageIO.write(image, "jpeg", byteArrayOutputStream);
byte[] imageByteArray = byteArrayOutputStream.toByteArray();
URL url = new URL("http://<host>:<port>");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
OutputStream outputStream = connection.getOutputStream();
outputStream.write(imageByteArray, 0, imageByteArray.length);
outputStream.close();
connection.connect();
// alternative to connect is to get & close the input stream
// connection.getInputStream().close();
} -
How to get a string of an HTML element
Imagine a normal web page with its tags. I have to get the
value of a precise element and convert it to a String in order to
show it in a TextField. Specifically, I have to take a precise cell
of a table and insert it in a string.
Does AIR help me with some method that catches specific
elements of a HTML code or have I to parse the string of the entire
HTML and try to reach the wanted value?
In this last case, how do I convert the entire HTML of a page
into a string?
Any other ideas are welcome.
Thanks.quote:
Originally posted by:
Marco Sgna
Does AIR help me...
No, but I don't see that it has to. I presume
you're writing an AIR app with HTML and JavaScript. If so, you can
query and modify the HTML's DOM tree with JavaScript. Then, still
using JavaScript, you pass it off to the AIR side, using the "AIR
aliases" APIs. So:
<table><tr><td
id="foo">bar</td></tr></table>
<script>var mycontent =
document.getElementById('foo').innerHTML; // variable equals "bar"
now</script>
quote:
how do I convert the entire HTML of a page into a string?
document.toString(), perhaps. -
How to get the string's byte length?
I have some string,I want to get the string's byte length,how
can do it?
for example:
<cfoutput>#len('hihi,这是测试')#</cfoutput>
output is 9
I want to get the byte length is 14, how can i get it?
Thanks.>> Fair cop. I didn't realise that asc() returned the
codepoint rather than the
> actual character code.
>
> and what would be the difference?
Oh, sorry, whatever the term is (I'm crap with jargon). The
value returned
by asc() for those chars was only two bytes (ie: four hex
digits). I
didn't realise there was more to it than that, and that
2-byte value maps
to some other THREE byte value. I need to do some reading...
> that's what both cf & java counted as the length.
CHARACTER length, sure. No-one's disputing that. On the other
hand,
no-one's asking about it, either.
> by adding a BOM you've already effected the encoding,
which may or may not
> match the original. so you still don't know how many
bytes were in the original
> string.
[groan]
Yes, that's a reasonable strawman there. I was only putting
it in a file
so I could save it and check the number of bytes occupied by
the data.
Clearly... CLEARLY... the OP is not asking for a character
length of that
string. They've said as much.
I copy and pasted the string from their post, and used it as
a
demonstration of how "nine" is not the right answer for the
BYTE LENGTH of
that string. Whether or not the original string was UTF-8,
UTF-16 or
special-marmoset-encoding, it almost certainly was NOT in a
fictitious kind
encoding in which each of those particular characters only
occupied one
byte each, which would mean that "nine" is the correct answer
to the
question.
When I copied those characters from either the web browser
for from my
text-based news agent, notepad identified them (and rendered
them
correctly) as UTF-8, so I'm fairly confident they ARE UTF-8.
Of course
this could be down to some intermediary encoding (pasting
them in to the
original posting, for example, via some encoding-transforming
mechanism),
but Occam's Razor suggests the original question was from a
UTF-8 POV.
But maybe we should quit speculating and ask the OP. Unless
they've
buggered off in despair of how drawn out all this is getting.
For which I
would not blame them.
Adam -
How to get Chinese string in the database?
Hi,
My dear friends.
I successfully connect the database, the data in the table as shown below
When I try to get "小明", but the following results were obtained
Does anyone know why, and how to get the correct result?
Thank you.You need to be aware of character conversions. Look at WideString, it support UTF32 chars.
-
How to get the upload file from a html form ?
I have a <input type=file ...> control in my form, and the user use that
control to submit a file
to my web server. The porblem is the getParameter() function of
HttpServletRequest only return the
filename. Does anyone know how to get the file body ?
Frances
http://www.servlets.com/jsp/examples/ch04/index.html#ex04_17
Frances Fan <[email protected]> wrote:
> I have a <input type=file ...> control in my form, and the user use that
> control to submit a file
> to my web server. The porblem is the getParameter() function of
> HttpServletRequest only return the
> filename. Does anyone know how to get the file body ?
> Frances
Dimitri
-
How to search a string in all opened html report ?
Hey people .. Sorry to bother U again.. I have a problem again.. and thanks to solve my previous problems...
I want to make an application in which I want to search a result string
in all opened Html reports... If I don't want to go to the all
desination and search one by one.. Is there any method to search the
result in all opened reports at that time..
I am very confulsed .. I have no Idea how I am gonna solve it... If anybody can help.. I would really appreciate that.. Thanks..Thanks Justin I have managed that problem..
I am stuck at another one.. If you can help.. I have also posted addressing you in another relavent Thread..
I have a spreadsheet data which has 286*516 Pixels data. Data is 16bit
(from which only 12bit is usefull). Each data is a Level of a Pixel. I
want to Display Grayscale Image.
I have used 3D Graph to display it and projection XY selected . I am
getting My image as grayscale Image but somewhat slow display if I
continously run it.
Second Method I tried is Directly "some 2D Graph" ( Sorry I forgot the
Name.. I will get it next time) which directly display that 16 bit
spreadsheet file. But it has only 255 levels so it didn't utilized my
data and resolution is poor.
My doubts are..
1. Is 3D graph method I am using is Actually displaying my 16 bit image.
2. In 3D graph method : Because of that 12 bit format of my data and I
had to convert it in 16 bit I am loosing any levels or
Resolution ?
3. Is there any way of increasing 255 level to 16bit level 2D Graph method.
4. Is there any method that can display my 16bit information as a image utilizing all my levels.
Please Do me a favor .. thank you -
How to get the material list displayed in CU50 transaction into ABAP report
How to get the 'KMAT" type material list displayed in CU50 transaction into ABAP report?
I am getting the entire BOM when i am using the FM CS_BOM_EXPL_MAT_V2 in to the table in the report.
But I want only the material list displayed in CU50.Hi,
Could you please tell us how you found a solution to your problem?
Thanks & regards
Hassan -
How to get the measure of area in HTML by Java
Hi all,
I know in JavaScript,
clientheight and clientlength can get the measure of area of HTML element, but how can I implement this in Java?
I understand I may need to have a much complete browser component first (for weak HTML rersolving in JDK), but I would like to know how HTML rendering works in JEditorPane and JTextPane, maybe that can help me solve the problem.
Appreciate for any suggestions and references.
Best regards,
KaiLiangThanks lots!!
So, the View class in JDK does not deal with the width and length information, does it?
If I want to solve my problem, I have to customize View class to make it can deal with width and length information.
Is it possible to get width and lenth of elements when JEditorPane render the HTML? -
How to get LOV column's DISPLAY value in IR report?
Hi,
I would like to get LOV column's DISPLAY value to trigger another javascript function. Could you please provide any hint?
For example, there is one IR report with 2 column, DEPT_NAME & SHOW.
The DEPT_NAME type is LOV .
The SHOW column is one link image, when clicking it , I would like to fire a javascript to get DEPT_NAME 's display value.
I know I can use #DEPT_NAME# to get the return value of LOV. However, how to get current row's DEPT_NAME's display value?
Thanks in advance.
Ray
Edited by: 最爱用中文 on 2013-4-11 下午4:14Is there any way you can create a table join, instead of using LOV as your display type?
That way you can select the name of the department in your IR query, display it as text, and then easily reference it as #DEPARTMENT_NAME#, for example. -
DbGetQuery = How to get the results to display?
I am using the following
sqldata <- dbGetQuery(con," select sysdate from dual")
How do I get the result to display?
summary(sqldata) displays the values
if I do dbSendQuery then fetch show the results
help(dbSendQuery) and help(dbGetQuery) go to the same page! dbSendQuery
The documentation says dbGetQuery will connect, get the records and clear; maybe the clear happens before the display?!Hello Amin,
Here is the way to display the result from the query you provided:
Assign the result of the query to object 'sqldata':
R> sqldata <- dbGetQuery(con," select sysdate from dual")
Type the object name at the R prompt:
R> sqldata
SYSDATE
1 2014-04-28 14:45:14
Sherry
Maybe you are looking for
-
How else can I get my password if I forgot it to log in? Besides just using the hint?
I have two user accounts on my macbook pro. One I use for mostly everything, and the other is just for editing videos and stuff. I haven't been on that second one in a while, and I just recently tried to log onto it and it is saying my password is in
-
Do I need to pay $99/year per employee just to test web pages on IOS simulator?
Hi there, I run a small web development shop with 5 employees. We all bought Xcode through the app store and have been using the iOS simulator to test web pages and troubleshoot problems with our customers sites on iPhones and iPads. I just upgraded
-
Hi, It happens often that when I try to set a destination like a big city, situated at..500-700km from my positions, Nokia drive can't find it...it shows me a street with the name or another city with a similar name, but not the location I'm searchin
-
Ok. so below is the code and in red shows syntax error ??? please help anyone as im new to all of it.. <?php // Set email variables $email_to = '[email protected]'; $email_subject = 'Form submission'; // Set required fields $required_fields = arr
-
(Groovy Expression) Get the no. of days between two dates
Hi All, I am using ADF-BC-11g to create an entity object with 2 specific columns ActualDate and EstimatedDate both of Date type. I also want an additional field DaysBetweenTwoDates showing the difference between these two dates. Hence, I add another