Spring Error in dynamic attributes - spring

I work with Eclipse Juno, Spring 3.2.6.RELEASE, Weblogic 10.3.6.
I have the following jsp
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%# taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<form:form id="create-survey" method="POST" action="/eusurvey/noform/management/createNewSurvey" style="display: none">
<input type="hidden" name="shortname" id="create-survey-shortname" value="" />
<input type="hidden" name="uuid" id="create-survey-uuid" value="" />
<input type="hidden" name="original" id="create-survey-original" value="" />
<input type="hidden" name="security" id="create-survey-security" value="" />
<input type="hidden" name="audience" id="create-survey-audience" value="" />
<input type="hidden" name="surveylanguage" id="create-survey-language" value="" />
<textarea style="display: none;" name="title" id="create-survey-title"></textarea>
<input type="hidden" name="listform" id="create-survey-listform" value="" />
<input type="hidden" name="contact" id="create-survey-contact" value="" />
<input type="hidden" name="contactlabel" id="create-survey-contact-label" value="" />
</form:form>
When I execute the application, I get the error:
weblogic.servlet.jsp.CompilationException: Failed to compile JSP /WEB-INF
/views/auth/tos.jsp
tos.jsp:79:21: Error in "menu.jsp" at line 358: The method
setDynamicAttribute(null, String, String) is undefined for the type FormTag
<%# include file="../menu.jsp" %>
^-----------^
at weblogic.servlet.jsp.JavelinxJSPStub.reportCompilationErrorIfNeccessary(JavelinxJSPStub.java:226)
at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:162)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:256)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:216)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:244)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:327)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
What does this error mean?. What are dynamic attributes?

It looks to be a classloading issue between your Spring and the one bundled into JRF.
Similar questions:
Weblogic 10.3 issues with spring 3.1.0 jsp compilation
Weblogic 10.3.5 Overriding Spring Version
It looks the quicker solution is to filter with prefer-web-inf-classes tag at weblogic.xml

Related

Attribute modelAttribute invalid for tag form according to TLD

I am trying to create a form:form but every time I have the model Attributr tag I get the following error!
There was an unexpected error (type=Internal Server Error, status=500).
/WEB-INF/views/start.jsp (line: 17, column: 0) Attribute modelAttribute invalid for tag form according to TLD
Here is my JSP code
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Official Sars-CoV3 Test Report</title>
</head>
<body>
<form:form action="addResults" modelAttribute="results">
<label for="tTN">TTN: </label><br>
<input type="text" id="tTN" name="tTN"><br>
<label for="fullname">Full Name:</label><br>
<input type="text" id="fullname" name="fullname">
<label for="email">Email:</label><br>
<input type="text" id="email" name="email">
<label for="age">Age:</label><br>
<input type="text" id="age" name="age">
<label for="gender">Please select Gender:</label>
<input type="submit" value="submit">
</form:form >
Admin Login
</body>
</html>

Using spring form tag inside a custom JSTL library

I need to create a custom JSTL tag which wraps multiple spring form tags. A single tag which produces the below content with custom attribute values as well.
<div class="col-md-4 col-sm-6 cal-xs-12">
<div class="form-group">
<label for="statusCode">Employee Status Code: </label>
<form:input path="statusCode" class="form-control" id="statusCode" value="${statusCode}" />
</div>
</div>
Is this achievable?
create a file formInputFiled.tag inside WEB-INF/tags/form directory.
formInputFiled.tag:
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%# attribute name="id" required="true" rtexprvalue="true" %>
<%# attribute name="path" required="true" rtexprvalue="true" %>
<%# attribute name="label" required="true" rtexprvalue="true" %>
<%# attribute name="value" required="true" rtexprvalue="true" %>
<%# attribute name="parentDivClass" required="true" rtexprvalue="true" %>
<%# attribute name="divClass" required="true" rtexprvalue="true" %>
<%# attribute name="inputClass" required="true" rtexprvalue="true" %>
<div class="${parentDivClass}">
<div class="${divClass}">
<label for="${id}">${label}</label>
<form:input path="${path}" class="${inputClass}" id="${id}" value="${value}" />
</div>
</div>
Add taglib declaration in your jsp like below:
<%# taglib prefix="form" tagdir="/WEB-INF/tags/form" %>
Finally use the new tag like below:
<form:formInputFiled id="statusCode" path="statusCode" label="Employee Status Code:" value="${statusCode}" parentDivClass="col-md-4 col-sm-6 cal-xs-12" divClass="form-group" inputClass="form-control"/>

Set a value for <form: input> in Spring's form tag library

How can I possibly set a value for a form input field using the form tag library in Spring MVC shown below even if it has no value attribute and is not accepted according to form tld?
<form:input path ="name" id="name" cssStyle="display: none"/>
Not based on requirement:
<input type="hidden" id="name" value="Raven"/>
Don't use a <form:input>? It's for binding to beans.
You can use a regular <input> element ;)
If you want to set its value:
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:set var="name" value="Raven" />
<input type="hidden" name="name" value="<c:out value='${name}' />" />

Using Spring Security, how to stay on the login page after a successful login?

Using Spring Security, how can I stay on the login page after a successful login?
This part of my Spring config file:
<http auto-config="true" use-expressions="true">
<form-login authentication-failure-url="/index.jsp?failed=true" default-target-url="/index.jsp" />
<logout logout-success-url="/index.jsp" />
</http>
And I have a jsp fragment file /WEB-INF/jsp/subhead.jspf:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<c:url var="postLoginUrl" value="j_spring_security_check" />
<c:url var="logoutUrl" value="j_spring_security_logout"/>
<c:if test="${param.failed == true}">Login Failed...</c:if>
<security:authorize access="isAnonymous()">
<form action="${postLoginUrl}" method="post">
Username: <input type="text" name="j_username"/>
Password: <input type="password" name="j_password" />
<input type="submit" value="Log in"/>
</form>
</security:authorize>
<security:authorize access="isAuthenticated()">
Hi, <security:authentication property="principal.username"/> Log out
</security:authorize>
I have a page say test.jsp:
<html>
<body>
<%# include file="/WEB-INF/jsp/subhead.jspf" %>
</body>
</html>
How can I make
login success
login failed
logout
all redirect back to the login page (test.jsp)?
For now, they will all redirect to /index.jsp.

How to make Struts and Prototype work better together?

Prototype library uses $('element-id') or $F('element-id') to get the element or value of a form element. This is very convenient to code in javascript. But in Struts, I find there is no way to define an id attribute for a form element.
Although i can use
<html:xhtml/>
to define a form tag with id attribute as follows:
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<%# taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%# taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<html:xhtml/>
<html:form action="/Welcome">
...
<html:text property="username" size="16" maxlength="18"/>
...
</html:form>
The above rendered html is like this:
<form id="TestForm" method="post" action="/myapp/Welcome.do">
...
<input type="text" name="username" size="16" maxlength="18"/>
...
</form>
But what i need is to let struts render the
<html:text>
tag like this:
<input type="text" id="username" name="username" size="16" maxlength="18"/>
So is it possible in Struts to realize that? Or if not, how can i make it better to code in Prototype lib for Struts application?
I am using Struts 1.3.8; Prototype 1.5.1.
You can use the styleId attribute on most Struts widgets to set the HTML element id:
<html:text styleId="myId" .../>
renders as
<input type="text" id="myId" .../>

Resources