473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Line break in Java

61
Hi
I am currently learning JSP and was wondering how you would implement a line break?

Expand|Select|Wrap|Line Numbers
  1. <%              java.util.Date d1;
  2.            java.util.Date d2;
  3.  
  4.            d1= new java.util.Date();
  5.            d2 = new java.util.Date();
  6.  
  7.            out.println(d1);
  8.            out.println("\n");
  9.            out.println(d2);
  10.  
I thought the line would do the trick but it didn't. The out put is:

This is the heading

This is the body

Fri Aug 14 23:04:55 PDT 2009 Fri Aug 14 23:04:55 PDT 2009
Basically I wanted to have the two dates in two lines.

Anyone any idea? Thanks.
Aug 14 '09 #1
7 25926
JosAH
11,448 Expert 8TB
You are printing HTML code right? A "<br>" tag prints a new line in HTML, so simply print that tag.

kind regards,

Jos
Aug 14 '09 #2
Alien
61
Yes its HTML but I dont think you can insert any HTML or non-Java stuff between <% %>

I tried it didn't work. But outside that yes, <br> works like it normally would.
Aug 14 '09 #3
Alien
61
Oh I think I get what you mean,

Some thing like this:

date 1 is : <%= d1%> <br>
date 2 is : <%= d2%>

and putting the remainder in a scriplet <% %>.

Thanks.
Aug 14 '09 #4
r035198x
13,262 8TB
You don't really want to use those scriplets in JSPs these days.
Better keep all the Java code in 'pure' servlets or in separate helper Java functions.
You can use EL to access objects in various scopes too.
Aug 14 '09 #5
JosAH
11,448 Expert 8TB
@Alien
Simply do a out.println("<br>") just as the OP was doing with his dates?

kind regards,

Jos
Aug 14 '09 #6
karthickkuchanur
156 100+
System.getProperty("line.separator");
Aug 18 '09 #7
esami
1
I think the problem here is that JSP pages. They require HTML style line breaks (like any HTML documents). So, try using "<br />" instead of "\n".
Aug 18 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roland Dalmulder | last post by:
Hello all, In my PHP script I put a text file into a string. Part of that string is read, changed and removed. The while loop continuest to extract the next part of the string. This goes all...
5
by: Wai Yip Tung | last post by:
When I do for line in fp: the line string usually has a '\n' at the end. In many cases I don't want the line break character. I can trim it using if line.endswith('\n'): line = line ...
5
by: Kathryn | last post by:
Good morning! I am having a problem with a span. I have items, of which I only want to show the first X characters on the screen. If the user prints the page, I want the entire item to print....
6
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
1
by: questionz_99 | last post by:
How would I specify line breaks of specific height? For example, if I wanted to insert a 6-point line break, what would the CSS code look like? Obviously, I'd like something more specific than...
3
by: lmawler | last post by:
Hi all, I know when I do data entry, I can force a line break in a text box by using Control & Enter. I'm trying to insert a line break in a field (that behaves like Control Enter) from VB. ...
4
by: deerchao | last post by:
Hi, I'd like to render colorful text with word wrap on screen (kind of inline <fonttag to change text color in html), but run into the line break problem. Graphics provides several DrawString...
1
by: mccalla | last post by:
Hi all, Tricky question. I know how to remove line break characters and spaces by using the code below: $message =~ s/\n//g; $message =~ s/\s//g;
7
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.