Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7600921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:02:15+00:00 2026-05-30T23:02:15+00:00

(For just multi-line strings in Java, see: Java multiline string . This question below

  • 0

(For just multi-line strings in Java, see: Java multiline string. This question below may bleed out into different answers considering the web app and HTML output context.)

Is there a way to enter multiple lines of text (stored a String) as Java code without formatting it?

I’d like to avoid:

  1. "..." + format on each line (necessary to wrap a text in Java)
  2. escaping quotation marks contained within the text.
  3. avoid \n for breaks on each line

It’s a MVC webapp and it’s HTML code I am outputting, fitted with some variables here and there. The string in question is so long as it’s an entire row of a table, where each row contains values such as id, key, value, etc. The .jsp file just has a single variable that contains the eventually output of all these rows, generated by a Java method. I’ve done the same with drop down boxes in forms, generating maybe options, <option>...</option>, but that code was small and tight when generated with Java. These rows I am stuck on are are large and complicated by comparison. I want the output HTML to be readable.

Likely not, but had to ask. Never know what you might miss.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:02:16+00:00Added an answer on May 30, 2026 at 11:02 pm

    I guess you ask this question because you are going to keep a really big string(s) in your Java code. And this is bad.

    Code and resources are different things, and mixing them is not recommended. Java provides a number of ways to manage resources, you can use Properties to store plain text/HTML resources, and ResourceBundle to store localized resources.

    PS You mentioned variables – you’re not concatenating them I hope? Putting something like foo=bar{0} in resource bundle and then doing String.format(bundle.getString("foo"), fooNum); should be a preferred way.

    edit

    Concerning the Java variable containing the whole HTML table – that’s why JSP Custom Tags were invented, – to encapsulate your weird HTML-generation logic. Implementing HTML table generation logic with JSTL in Tag Files is the way to go – you won’t need to compile anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare the equality of two multi-line strings. I'm getting one of
I have a string like: [a b=c d=e]Some multi line text[/a] Now the part
string could be anything @username is the link in multi-line string.. we need to
Is there a cross-platform library function that would collapse a multiline string into a
Let's say I have the following multi-line string: # Section ## Subsection ## Subsection
All is in the title : here is the string pattern of a multi-line
Need to parse a Class declaration line in Java using regular expression e.g. String
CURRENT PROGRESS TOWARD SOLUTION: This is the updated code: sql = INSERT INTO Strings
I'm trying to prepend a string a read-only, multi-line TextBox using the following code:
Normally it just puts multiline content on a one liner field and adds slightly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.