jsp-tags

How can I pass an object to a JSP tag?

此生再无相见时 提交于 2019-12-03 09:33:59
I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache. For example I would like to accomplish this: <%@ taglib prefix="wf" uri="JspCustomTag" %> <% Object myObject = new Object(); %> <wf:my-tag obj=myObject /> I'm trying to avoid directly interacting with any of the caches (page, session, servletcontext), I would rather have my tag handle that. dfrankow A slightly different question that I looked for here: "How do you pass an object to a tag file?" Answer: Use the "type" attribute of the attribute

Checking attribute exists in JSP

痞子三分冷 提交于 2019-12-03 05:26:13
问题 I have some classes which extends a superclass, and in the JSP I want to show some attributes of these classes. I only want to make one JSP, but I don't know in advance if the object has an attribute or not. So I need a JSTL expression or a tag which checks that the object I pass has this attribute (similar to in operator in javascript, but in the server). <c:if test="${an expression which checks if myAttribute exists in myObject}"> <!-- Display this only when myObject has the atttribute

how to load CSS file into jsp

隐身守侯 提交于 2019-12-03 04:29:22
I created a jsp page as follows: <%@ page contentType="text/css" %> <html> <head> <title>Login page</title> <link href="/css/loginstyle.css" rel="stylesheet" type="text/css"> </head> <body> <h1> India welfare</h1> <p> welcome </p> </body> </html> and named it as login.jsp and i also created a css file called loginstyle.css and the code of the .css file is as follows: body { background-color:#d0e4fe; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-size:20px; } the directory structure for css and jsp's are as follows: webcontent/welfare_web/css for .css files

Scope of jsp:useBean

試著忘記壹切 提交于 2019-12-03 04:08:07
home.jsp <jsp:useBean id="username" class="java.lang.String" scope="application"/> <% username="Jitendra"; %> <jsp:include page="include.jsp"/> include.jsp <%=username%> This gives an error saying “username” is undefined in include.jsp, even though the scope of Bean is application… BalusC As to your problem, anything which you declare locally using the old fashioned scriptlets is not linked with a jsp:useBean . Also, declaring a local scriptlet variable is not visible in the included pages, you need to explicitly put them in at least the request scope. As using scriptlets is a bad practice . I

Printing a java scriptlet variable as if it is a JavaScript variable

浪子不回头ぞ 提交于 2019-12-02 20:06:35
问题 hello i need to output a java variable inside a javascript call inside a tag inside a jsp ! for example: <% String param = "hello";%> <dmf:checkbox name="checkbox" onclick = "selectAll(<%=param%>)" /> the javascript generated is: selectAll(<%=param%>),this); but I actually want something like selectAllCheckBoxes(Hello),this); 回答1: That's not escaping. That's just printing a scriptlet variable as if it is a JavaScript variable. Besides, your examples are confusing, they doesn't match each

Checking attribute exists in JSP

廉价感情. 提交于 2019-12-02 19:54:13
I have some classes which extends a superclass, and in the JSP I want to show some attributes of these classes. I only want to make one JSP, but I don't know in advance if the object has an attribute or not. So I need a JSTL expression or a tag which checks that the object I pass has this attribute (similar to in operator in javascript, but in the server). <c:if test="${an expression which checks if myAttribute exists in myObject}"> <!-- Display this only when myObject has the atttribute "myAttribute" --> <!-- Now I can access safely to "myAttribute" --> ${myObject.myAttribute} </C:if> How can

Using the POST Method with HTML Anchor Tags

杀马特。学长 韩版系。学妹 提交于 2019-12-02 19:03:24
I am certain the answer will be 'NO', but I wanted to ask anyway just incase I have missed something. Everyone knows that one pass data to a page in an anchor tag by using the GET method: What I am wondering is if there was a way to do the same thing, but use the POST Method instead? My purpose in doing so is to keep the URLs the user sees clean by not putting anything in them that they do not need to see. This has nothing to do with security concerns as I already know there would be ways to obtain the data being passed. If the answer is indeed no, then what methods do people use to pass data

How could I get a parameter in JSP?

孤人 提交于 2019-12-02 17:52:57
问题 Here is my action execute() method, @Override public String execute() throws Exception { ActionContext aContext = ActionContext.getContext(); aContext.getParameters().put("reqVar1", "reqVar1-Value"); return SUCCESS; } I want to get the parameter value in JSP like below code, <s:property value="#parameters.reqVar1" /> but it doesn't work. I see the parameter is in stack context: How could I get the parameter value in JSP? 回答1: Parameters are always use a type Map<String, String[]> . And you

In Struts1.3 How Handling Multiple FormBean property to action

心已入冬 提交于 2019-12-02 17:28:35
问题 I am using Struts1.3, I have Jsp page which is showing the list of employees on that page. For this what i did is, I have a action inside that action i am calling a function which returns List and i am setting these list inside the session as session.setAttribute(Constant.EMPLIST,list). And now in my Jsp page i am using logic tag to iterate this list as below given. <html:form method="post" action="test.do" styleId="empForm"> <logic:iterate id="EmpForm" name="<%=Constant.EMPLIST%>"> <table>

In Struts1.3 How Handling Multiple FormBean property to action

夙愿已清 提交于 2019-12-02 11:51:34
I am using Struts1.3, I have Jsp page which is showing the list of employees on that page. For this what i did is, I have a action inside that action i am calling a function which returns List and i am setting these list inside the session as session.setAttribute(Constant.EMPLIST,list). And now in my Jsp page i am using logic tag to iterate this list as below given. <html:form method="post" action="test.do" styleId="empForm"> <logic:iterate id="EmpForm" name="<%=Constant.EMPLIST%>"> <table> <tr> <td> <html:text property="empName" name="EmpForm" styleClass="fieldbox2" styleId="textfield50"/> <