A VS Code extension for formatting JSP (JavaServer Pages) files with comprehensive support for mixed content including HTML, JavaScript, Java, CSS, and JSP-specific syntax.
Features
- Automatic JSP Formatting: Format
.jsp files with proper indentation and structure
- Multi-Language Support: Handles the complex mix of languages in JSP files:
- HTML markup
- JavaScript code within
<script> tags
- CSS code within
<style> tags
- Java code in JSP scriptlets
<% %>
- JSP expressions
<%= %>
- JSP declarations
<%! %>
- JSP directives
<%@ %>
- JSP Comment Support: Properly formats JSP comments
<%-- --%> and HTML comments <!-- -->
- Smart Indentation: Automatically handles nested structures and code blocks
- Configurable: Respects VS Code's formatting settings (tab size, spaces vs tabs)
Usage
- Open a
.jsp file
- Press
Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS)
- Or right-click and select "Format Document"
- Or use Command Palette:
JSP Formatter: Format JSP Document
Enable format on save in your VS Code settings:
{
"[jsp]": {
"editor.formatOnSave": true
}
}
Requirements
- VS Code version 1.108.1 or higher
Extension Settings
This extension respects the following VS Code settings:
editor.tabSize: Number of spaces for indentation
editor.insertSpaces: Use spaces instead of tabs
Examples
Before formatting:
<%@page contentType="text/html"%>
<html>
<head>
<title>Example</title>
<style>
body {
background-color: white;
}
</style>
</head>
<body>
<h1>Hello</h1>
<%
String message = "World";
out.println(message);
%>
</body>
</html>
After formatting:
<%@page contentType="text/html"%>
<html>
<head>
<title>Example</title>
<style>
body {
background-color: white;
}
</style>
</head>
<body>
<h1>Hello</h1>
<%
String message = "World";
out.println(message);
%>
</body>
</html>
Known Issues
- Complex nested structures may require manual adjustment
- Some advanced JSP tag libraries may not format perfectly
Release Notes
0.0.1
Initial release of JSP Formatter:
- Basic JSP file formatting
- Support for HTML, JavaScript, Java, and CSS
- JSP-specific syntax support (comments, directives, scriptlets, expressions)
- Configurable indentation settings
Contributing
Found a bug or have a feature request? Please open an issue on the GitHub repository.
License
This extension is provided as-is for educational and commercial use.
Enjoy formatting your JSP files!