Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to show "message" line after line in browser?  RSS feed

 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to show the output ( A String message) in my result JSP line after line. but currently it displays the "message" as a single string.. Is there a way to do it in JSP? Any help much appreciated..



Regards,
Sapumal.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HTML, a new line is indicated by a <br> element, or by a new block element such as <div>.
 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault, It doesn't work.. Here I post my JSP and Servlet..

Servlet method// Where the returnVal is set to "message"



result.jsp







 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless

Are you formatting the HTML correctly to display line breaks? Newlines in HTML are meaningless.
 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I catch the passed message in JSP ? and pass it to a javascript method?

request.getAttribute("message") doesn't suppose to be working..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sapumal Bandara wrote:How can I catch the passed message in JSP ?

You already appear to be doing that with the EL.

and pass it to a javascript method?

You can't; not directly. You'll need to use JSP to create JavaScript source int he page that will be interpreted once the page reaches the browser.

request.getAttribute("message") doesn't suppose to be working..

That's Java code that would appear in a servlet. It's not JavaScript and can't be used for JavaScript.
 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sapumal Bandara wrote:request.getAttribute("message") doesn't suppose to be working..


What is the output you are getting in the browser for result.jsp??
 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can't; not directly. You'll need to use JSP to create JavaScript source int he page that will be interpreted once the page reaches the browser.


Bear Bibeault can you explain a bit more what you mentioned above..?

And Ishan Pandya here is the output;


Regards,
Sapumal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!