How to Append a String to Another String in Struts 2 in JSP

Concatenating two strings lets you append one string to the end of another using the common struts 2 design method. Struts standardizes coding, so you can stick to practices in your code that make it easier for other programmers to read and edit your code. The "+" character combines strings in your JSP code.

Instructions

    • 1

      Right-click the JSP file you want to edit and select "Open With." Select your preferred JSP editor.

    • 2

      Create the two strings you want to use. The following code creates two strings you can concatenate:

      String str1 = "First String";
      String str2 = "Second String";

    • 3

      Append the second string to the first string using the "+" character. The following code appends "str2" to "str1":

      String appended = str1+str2;

    • 4

      Print the results to the user's screen. The following code displays the new string to the user:

      System.out.println(appended);

Related Searches:

References

Comments

Related Ads

Featured