struts-jsp-patterns
Struts 1.x/2.x and JSP anti-patterns, code archeology patterns, and legacy code understanding. For software archeology consulting.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Struts 1.x/2.x and JSP anti-patterns, code archeology patterns, and legacy code understanding. For software archeology consulting.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Manage project board — issues, sprints, status tracking, acceptance verification, and release management. Supports GitHub Projects, Jira, and YouTrack via pluggable providers.
Manage project board — issues, sprints, status tracking, acceptance verification, and release management. Supports GitHub Projects, Jira, and YouTrack via pluggable providers.
Happy path smoke testing — navigates all configured endpoints, checks HTTP status and server logs for errors, and optionally auto-creates GitHub issues for failures. Config-driven via CC_SMOKE_TEST_* variables.
Manage GitHub Project board — issues, sprints, status tracking, acceptance verification, and release management. White-labeled template for any project.
Check for and apply cognitive-core framework updates. Compares installed agents, skills, and hooks against the framework source, shows available updates, and safely applies them.
Check for and apply cognitive-core framework updates. Compares installed agents, skills, and hooks against the framework source, shows available updates, and safely applies them.
基于 SOC 职业分类
| name | struts-jsp-patterns |
| description | Struts 1.x/2.x and JSP anti-patterns, code archeology patterns, and legacy code understanding. For software archeology consulting. |
| user-invocable | false |
| allowed-tools | Read, Grep, Glob |
| catalog_description | Struts/JSP anti-patterns, legacy code archeology, and modernization assessment. |
Software archeology reference for understanding and assessing legacy Java web applications.
| Indicator | Version | Location |
|---|---|---|
struts-config.xml | Struts 1.x | WEB-INF/ |
struts.xml | Struts 2.x | src/main/resources/ or classpath |
tiles-defs.xml | Tiles 1.x/2.x | WEB-INF/ |
<% ... %> scriptlets | JSP (any) | *.jsp files |
ActionForm extends | Struts 1.x | Java source |
ActionSupport extends | Struts 2.x | Java source |
web.xml with ActionServlet | Struts 1.x | WEB-INF/web.xml |
web.xml with StrutsPrepareAndExecuteFilter | Struts 2.x | WEB-INF/web.xml |
<%@ taglib uri="/WEB-INF/struts-*.tld" | Struts 1.x | *.jsp |
<%@ taglib prefix="s" uri="/struts-tags" | Struts 2.x | *.jsp |
Browser Request
|
v
web.xml (ActionServlet mapping: *.do)
|
v
struts-config.xml (action-mappings)
|
v
ActionForm.validate() → validation errors → input JSP
|
v
Action.execute(mapping, form, request, response)
|
v
ActionForward (name → path in struts-config.xml)
|
v
JSP (with Struts tag libs: html, bean, logic, tiles)
org.apache.struts.action.Action — controller base classorg.apache.struts.action.ActionForm — form data bindingorg.apache.struts.action.ActionForward — navigation resultorg.apache.struts.action.ActionMapping — URL-to-action mappingorg.apache.struts.action.ActionServlet — front controller servletorg.apache.struts.tiles.TilesPlugin — layout templatingorg.apache.struts.validator.ValidatorPlugIn — XML-based validation| Anti-Pattern | What to look for | Risk | Spring Boot equivalent |
|---|---|---|---|
| God Action | Action class >500 lines, handles multiple paths via if/else on form fields | High | Split into @Controller methods |
| ActionForm bloat | ActionForm with 30+ fields, nested objects | Medium | @RequestBody DTO + validation groups |
| Business logic in Action | Database calls, calculations in execute() | High | Service layer (@Service) |
| Request/Session abuse | request.setAttribute() / session.setAttribute() for everything | Medium | Model attributes, @SessionAttributes |
| Struts MessageResources as i18n | MessageResources.getMessage() scattered everywhere | Low | MessageSource + @MessageSource |
| DynaActionForm | Dynamic forms via XML — hard to refactor | Medium | Typed DTOs |
| DispatchAction abuse | Single action handles CRUD via method param | Medium | REST endpoints |
Browser Request
|
v
web.xml (StrutsPrepareAndExecuteFilter: /*)
|
v
struts.xml (package → action mapping)
|
v
Interceptor Stack (params, validation, fileUpload, exception, etc.)
|
v
Action class (POJO with execute() or method name)
|
v
Result (JSP, Freemarker, JSON, redirect)
| Anti-Pattern | What to look for | Risk | Spring Boot equivalent |
|---|---|---|---|
| OGNL in views | <s:property value="%{user.name}"/> with complex expressions | Critical (security) | ${user.name} in Thymeleaf |
| ServletRequestAware/SessionAware | Action implements *Aware interfaces | Medium | @RequestParam, @SessionAttribute |
| ValueStack manipulation | ActionContext.getContext().getValueStack() | High | Model/ModelAndView |
| Wildcard mappings | <action name="*" method="{1}"> | High (security) | Explicit @RequestMapping |
| Interceptor soup | 20+ custom interceptors in stack | Medium | Spring filters/aspects |
| Anti-Pattern | Example | Fix |
|---|---|---|
| Scriptlet logic | <% if(user != null) { %> | <c:if test="${not empty user}"> |
| Scriptlet DB access | <% Connection con = ... %> | Move to DAO/Service layer |
| Scriptlet import | <%@ page import="java.sql.*" %> | Remove — indicates wrong layer |
| No JSTL | HTML mixed with <%= request.getAttribute("x") %> | ${x} with EL |
| Inline CSS/JS | <style> and <script> in every JSP | External files, asset pipeline |
| Include vs Tiles | <%@ include file="header.jsp" %> everywhere | Tiles template inheritance |
| Form action hardcoding | <form action="/app/saveUser.do"> | <html:form action="/saveUser"> |
When first encountering a Struts/JSP codebase:
web.xml — understand servlet mappings, filters, listeners, context paramsstruts-config.xml or struts.xml — map all actions to Action classesfind . -name "*.jsp" | wc -lgrep -rl "extends Action" src/ or grep -rl "extends ActionSupport" src/pom.xml or lib/*.jar versionsgrep -rc '<%[^@=-]' webapp/ --include="*.jsp"find . -name "*Test.java" | wc -l*.do or action mappings| Category | Low Debt | Medium Debt | High Debt |
|---|---|---|---|
| Scriptlets | <10 across all JSPs | 10-100 | >100 |
| God Actions | None >200 lines | 1-3 large actions | >3 or >500 lines |
| Test coverage | >50% | 20-50% | <20% |
| SQL injection risk | Parameterized queries | Mixed | String concatenation |
| Dependency age | <5 years old | 5-10 years | >10 years |
| Build system | Maven 3+ | Maven 2 | Ant only |