jsp page auto removes whitespaces - java

I am writing lots of whitespaces as you can see the code below.
out.println("new Array('1453 12999 ALPER KOPUZ')");
unfortunately when code compiles and run the code in the screen I am able to see it as
"1453 1299 ALPER KOPUZ".
It means it auto removes whitespaces and put only one whitespace after one word.It works fine at older versions of Internet Explorer but it does show line such like "1453 1299 ALPER KOPUZ" at Internet explorer which I need to fix and our application runs on this server.
I tried css "white-space: pre;" but it is still same.
This problem makes me crazy and ate my 3 hours. I would be glad if you have any idea to fix it.
Cheers
Alper Kopuz

I guess using out.println you are writing the text as HTML on your page as response.
You need to have the text pre formatted once you print it as HTML. Try to put your text in pre tag as shown below.
out.println("<pre>new Array('1453 12999 ALPER KOPUZ')</pre>");
Let me know if this is what you were looking for.

Related

Weird sideeffect printing some escape sequence to InelliJ-console, why?

If I want to display the simple string "/\" on the IntelliJ-console by doing so:
System.out.println("/\\");
the console produces a hyperlink, which opens my Windows-Explorer if clicked on instead of the above expected output. I tried same code on IDE like Eclipse and NetBeans and it works like expected with no sideeffects. I asked other students working with IntelliJ, and they have the same results.
I solved the problem by appending a non visible white space \u2060 like this:
System.out.println("/\\\u2060");
Now my Question:
Is this a special feature in IntelliJ or some other feature (like regular expression stuff) I don't understand yet?

I dont understand this output produced by selenium webdriver java

I'm trying to write an application for the game Path of Exile, that lists the items in my stash on trading websites automatically.
For this I have to retrieve the items in my stash from their website. For some reason the ".getText()" functions is behaving very weird on the website. I really can't see any mistakes I did with the x-path Expressions.
Example:
Here you can see a snippet from the HTML file I am working on
screenshot of browser debugg tool
In the screenshot you can see that the x-Path I am using is selecting a element with a text element, however when I iterate over the elements and get the text with the getText() function, it returns a empty String... I really have no clue what I am doing wrong, is it the website, that is denying me to access the field?
In case it helps I add here a screenshot of the source code for outputting the text fields
printing the text of the elements(SourceCode)
5 empty Strings as output
On your place I would try to get value instead of text.
try to replace
e.getText()
with
e.getAttribute("value")
or you can also try to play with .getCssValue()

Underline/strikethrough text in HTML Java

I'm trying to see if there is a difference between making the text you entering to be underlined or struck through and the text you already enter to make it this way.
I'm working with Java and HTML.
In the Android Studio I can see that the HTML being written to the JTextPane is something like this:
<body>
<strike></strike>
</body>
but trying to type an 'a', does not produce a struck through 'a' symbol.
However, trying to type 'a', select it and then make it a strikethrough works as expected.
I'm checking for the presence of the HTML.Tag.S style in the HTML in order to see if the strikethrough is present or not in addition to the <strike> tag.
Also, if I refresh the window the text appears as it should, i.e. struck.
Changing the style of the font to become 'bold' also works as expected from the first time regardless if I select the existing text or I select the 'bold' and start typing the text.
Does anyone have an idea where should I look?

Display a scrolling message that can be updates by another webpage

I'm looking for a solution to this and I have searched the web for an answer with nothing. I need a scrolling message on my webpage that can be updated by the same website but on a different page. (e.g www.webpage.com <-- has the scrolling message on it, www.webpage.com/settings <-- has a form in which you can change/update the scrolling message)
I'm pretty sure this is achievable with Java, but my knowledge on Java is slim and all my efforts have come to a fail. I have managed to get a scrolling message on my webpage and I'm sure if I could read a text file (with the message in) then assign that to a 'var', I could make that scroll but I don't know how to do that.
If you know a completely different method of doing this I am happy to change mine.
Thanks in advance,
Tom.
I would recommend javascript instead of java, since java is not really conventional anymore and looks ugly too (and requires a special plugin).
It depends on how fast you want to update the scrolling text how you want to do this. I would say save the text to a .txt or database from settings, and then have your page get it.
You can then use php to read the value from the .txt file or database to display it on your website.
If you want it to be extremely up to date you can let javasript call a little .php file that reads the file and gives you the content.
To make your text scroll you don't really need anything other than html, like so:
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
You can read more about that here: http://www.quackit.com/html/codes/scrolling_text.cfm

Anchor not working in IE7 via redirect (spring-mvc, jsp)

So for this project I am doing I have a page which generates content via clickable buttons. The button posts the form to my controller and the controller acts on the button that has been clicked. To show what was changed a redirect will occur (form in the session) with an anchor included. A little piece of javascript will then go to anchor which is in the link (eg. website/add/picture#123). This works fine in pretty much every browser except Internet Explorer 7.. I found out this has to do with an input field of file type.. Because if I remove the input field, then even IE7 will nicely scroll to the anchor..
Does anyone have any idea why this behaviour occurs?
If it's unclear please tell me and I'll provide more details..
Thanks a lot,
Davey
So.. I didn't manage to solve the input type=file bug.. I suppose it's just an IE7 bug. I made a work around to put the input field on a popup. A lot of overhead but it is working pretty well now

Categories