Assiginment to varaibles from jsp tags
is it possible and how is it possible to assign something from jsp tag to an variable declared in scriptlet code - ie. - as below.
also is there a good resource for jsp info - a comprehensive lookup on jsp syntax egs on the web that any one is aware of. - thanks.
i 'm doing - can i use this variable as in below scrpitlet code :
<%! List myAbridgments = new ArrayList(); %>
then - Also at this stage it get a ClassCastException - why would i get that here i dont use this variable - results anywhere else - except in setting the session attribute in the original servlet that calls this jsp page
<jsp:useBean id="results" class="com.bt.ros.Results" scope="session">
<jsp:setProperty name="results" property="*"/>
</jsp:useBean>
the in some scrpitlet code doing:
<% myAbridgments = results.getAbridgments();
for (int i = 0; i < myAbridgments.size(); i++) {
abridgment = (Abridgment) myAbridgments.get(i);
//out.println(abridgment.geta_volume_id());
%>
<p><input type="checkbox" name="list" value="ON"><span style="font-size:12pt"><jsp:getProperty name="abridgment" property="a_sub_year_volume"/></span><span style="font-size:12pt">,
<a href="abridgment_link.htm"><jsp:getProperty name="abridgment" property="a_volume_id"/></a>, </span>
yeah, but this doesn't really help me. I am trying (really hard!) to ensure my JSP's don't really contain any "code" as such, just JSP tags.
The end result I want is to include one JSP in another. Now, I "could" just use a <jsp:include.., the problem is that the path to the file I want to include is tied up in an object which I have previously placed in the ServletRequest object. Again, I "could" extract this in the "parent" jsp, and pass it dynamically to the jsp:include, but I don't want any actual Java "code" in the JSP. (There IS a good reason for this, so I can't really comprimise).
The fact that the IS a pageContext.include() method tells me that I can use it. I must be doing something wrong though.
Thanks anyway.
Similar Messages
-
Urgent-how to access custom tag from jsp tag
I have a problem accessing a custom tag from a jsp expression.
Details: I have a custom tag that returns a string variable. I need to access that variable from jsp expression <%%>.
Can any body help me?Tags don't "return" values as in the normal sense.
They can only support TEI (Tag Extra Information) that just stuffs a declared variable into the page's state.
For example, if the tag class had a public method called getValue(), you could do the following:
<xmp:mytag id="foo"/>
<%
out.println("value is " + foo.getValue());
%> -
Calling PL/SQL stored procedure from JSP tag
Hello,
I need to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
Thank you
Syedneed to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
regards
Indira Rani Bandi -
Invoking getParent() from JSP tags
Hi,
I am writing a JSP tag that may only be invoke within a specific enclosing tag and I would like to invoke getParent() to get a reference to my enclosing tag but I can't seem to find out how to do this under JSP tag files. Any ideas?
Gilione way is to set the parent tag as an attribute on the pageContext when ur processing the parent tag.
example:
suppose there is a parent tag and child tag nested in it......
ParentTag.java
public ParentTag() {
public int doStartTag() throws JspException {
// set the parent as a page attribute - for the nested child tag ...
pageContext.setAttribute("someKey", this);
return EVAL_BODY_BUFFERED;
ChildOfParentTag.java
public ChildOfParentTag() {
public int doEndTag() throws JspException {
// Get the parent tag from the page context that was set previously
ParentTag parent = (ParentTag) pageContext.getAttribute("someKey");
}reg,
sien.. -
Passing params to custom tag from jsp
Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
Something like this:
// processed tag
<a href="mypage.jsp?page=1">Next page</a>
// clicking "Next Page"
<a href="mypage.jsp?page=2">Next page</a>
// jsp
<taglib:tag param="<%=getPageNumber()%>" />
// in tag lib
private pagenumber=1;
pagenumber++;
getPageNumber(){
return pagenumber;
setPageNumber(int pagenumber){
this.pagenumber=pagenumber
}I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
Any advice would be greatly appreciated.
Thanks :)Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
Something like this:
// processed tag
<a href="mypage.jsp?page=1">Next page</a>
// clicking "Next Page"
<a href="mypage.jsp?page=2">Next page</a>
// jsp
<taglib:tag param="<%=getPageNumber()%>" />
// in tag lib
private pagenumber=1;
pagenumber++;
getPageNumber(){
return pagenumber;
setPageNumber(int pagenumber){
this.pagenumber=pagenumber
}I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
Any advice would be greatly appreciated.
Thanks :) -
Calling JSP Tag Files from Coldfusion
I am trying to call a JSP Tag file from Coldfusion. I am
getting "Unknown Tag" error.
Here is the code I have.
<CFIMPORT TAGLIB="/WEB-INF/lib/mtgTags.jar"
PREFIX="mtg">
<mtg:chooseDate appId="1" />
mtgTags.jar contains a chooseDate.tag file.
I know CFIMPORT statement above is working fine. Can anyone
please tell why am I getting "Unknown Tag: chooseDate" error.
ThanksHi,
You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
Hope u got the answer...
Regards
ravi -
How to get the values of an Array using JSP Tags
Hey guys,
I need some help. I've splited a String using
fn:split(String, delim) where String = "1,2,3,4" and delim is ,
This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
Any help would be highly appreciated
ThanksThe JSTL forEach tag.
In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
<c:set var="list" value="1,2,3,4"/>
<c:forEach var="num" items="${list}">
<c:out value="${num}"/>
</c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string. -
How to get an ArrayList Object in servlet from JSP?
How to get an ArrayList Object in servlet from JSP?
hi all
please give the solution for this without using session and application...
In test1.jsp file
i am setting values for my setter methods using <jsp:usebean> <jsp:setproperty> tags as shown below.
After that i am adding the usebean object to array list, then using request.setAttribute("arraylist object")
---------Code----------
<jsp:useBean id="payment" class="com.common.PaymentHandler" scope="request" />
<jsp:setProperty name="payment" property="strCreditCardNo" param="creditCardNumber" />
<%-- <jsp:setProperty name="payment" property="iCsc" param="securityCode" /> --%>
<jsp:setProperty name="payment" property="strDate" param="expirationDate" />
<jsp:setProperty name="payment" property="strCardType" param="creditCardType" />
<%--<jsp:setProperty name="payment" property="cDeactivate" param="deactivateBox" />
<jsp:setProperty name="payment" property="fAmount" param="depositAmt" />
<jsp:setProperty name="payment" property="fAmount" param="totalAmtDue" /> --%>
<jsp:useBean id="lis" class="java.util.ArrayList" scope="request">
<%
lis.add(payment);
%>
</jsp:useBean>
<%
request.setAttribute("lis1",lis);
%>
-----------Code in JSP-----------------
In testServlet.java
i tried to get the arraylist object in servlet using request.getAttribute
But I unable to get that arrayObject in servlet.....
So if any one help me out in this, it will be very helpfull to me..
Thanks in Advance
EdwardHi,
Im also facing the similar problen
pls anybody help..
thax in advance....
Litty -
How to call RDF report from JSP page
Dear all,
I want to call a RDF report from JSP page. I am creating the JSP page using j developer 10G.
Can anyone help me out in this case. Is there any tag or procedure or any other way by of that i can perform this work.
please help and send the reply on [email protected],[email protected]
thanks
AshokHi Ashok,
You can use rwservlet - nothing really to do with JDeveloper. Once you have report server up and running (hint: read http://download-uk.oracle.com/docs/cd/B14099_19/bi.1012/b14048/toc.htm), you can call a report like this:
http://server:port/rwservlet?report=my_report.rdf&destype=cache&desformat=html&p_my_parameter=xxx etcHope this helps,
John -
Need help in writing data from JSP to excel
Hi ,
I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
I am using the following code in JSP.
"out.print(amt + '\t');"
Would like to know if there is any otherway where in i can get my requirement.
Thanks
TomHi,
Try using format part of the JSTL tag libs.
Syntax :
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber value="40" pattern="$#,##0.00"/>
I need help in writing the data from JSP to excel.I
somehow able to retrieve the data into excelHow do u convert the jsp to excel?
One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
response.setContentType("application/ms-excel")Hope this Helps.... -
UNABLE TO ACCESS SECURED EJB USING IIOP FROM JSP
Following codes does not work with IIOP when called from jsp returns an
com.sap.engine.services.iiop.CORBA.CORBAObject:com.sap.engine.services.iiop.server.portable.Delegate_1_1@8312b1 step2 RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create(). at
Following codes does not work with IIOP when called from a fat client returns an
org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe
at com.sun.corba.se.internal.core.UEInfoServiceContext.<init>(UEInfoServ
iceContext.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at com.sun.corba.se.internal.core.ServiceContextData.makeServiceContext(
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
p.put(Context.PROVIDER_URL, "iiop://hostname:50007");
p.put(Context.SECURITY_PRINCIPAL, "User");
p.put(Context.SECURITY_CREDENTIALS, "pass");
I have add java option to add IIOP filer
-Dorg.omg.PortableInterceptor.ORBInitializerClass.com.sap.engine.services.iiop.csiv2.interceptors.SecurityInitializer
Solution Required: Could you please detail me what steps in need to perform in order for me to access secure ejb using iiop protocol.
FYI -- How ever ejb security works with P4 protocol, If required i can send you the test case ear.
Thanks
Vijay
Following are the server side logs
java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create().
at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:91)
at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
... 20 more
; nested exception is:
java.lang.SecurityException: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)That's the code that you need to execute but you should
probably encapsulate that code in Custom Action.
Orion has a EJB Tag Library that is free to distribute that
does all that stuff you just set some attributes.
Go to their site and look at their Tag Libraries.
Also look for other Tag Libraries Freely Available for EJB Access. -
Passing value from JSP to scriptlet
Hi
I am trying to find a way to pass a value from jsp to the scriptlets, i.e.
<c:set var="testValue" value="123" />
<%
System.out.println(testValue);
%>
the above code just demonstrates what I was trying to achieve, by passing the value from the jsp into the scriptlet.
Can someone tell me if there's an easy way to do this?
Thank you.Note, using scriptlet code on your page is generally something to be avoided. 99% of what you should be doing on a JSP page can be done with EL/JSTL. If you can't do it with EL/JSTL then it probably belongs in a servlet/bean.
I always aim for 100% scriptlet free jsp pages.
Having said that, I can still answer your question: EL attributes are stored in the scope - page, request, session, application
${testValue} is equivalent to pageContext.findAttribute("testValue").
The <c:set> tag example doesn't specify a scope, so therefore you could get it like this:
<c:set var="testValue" value="123" />
<%
String testValue = (String)pageContext.getAttribute("testValue");
System.out.println(testValue);
%>alternatively exploit the feature of the useBean tag that creates a scriptlet variable:
<c:set var="testValue" value="123" />
<jsp:useBean id="testValue" type="java.lang.String"/>
<%
System.out.println(testValue);
%>Note that the EL variable and the Scriptlet variable are initially pointing at the same String.
But changing the string in scriptlet code will change the value it is pointing at, while leaving the EL variable untouched.
If you have a List in scope, and sharing it between EL and scriptlet variables then any changes to the list would be reflected because they both point at the same List object.
cheers,
evnafets -
How to call Generic Page flow from jsp
Hi All,
I have some links in my home page(jsp file).Based on user's selection, i need to show another JSP page using pageflow(JPF).
thanks in advance
vandanai have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks
-
How to call java class file from jsp
hi
we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
bye
siva sankariyou can call the methods in a lot of ways. you could use scriptlets with the
<%@ page import="package.class"%> and then inside instantiate an object
<%
MyClass mc = new MyClass(parameters if any);
mc.theMethodYouWantToCall();
%>or as Madathil has stated,
or use the JSP tags
<jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
or even Custom Tags -
How to call java script function from JSP ?
how to call java script function from JSP ?
i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks
Maybe you are looking for
-
Error while sending email to distribution list
Hello All, I am not able to send the email to Shared & Private distribution list. It is giving an error "Function <Send> not possible" I can send the email to users by specyfying their email id & recepient type as Internet address while sending mail
-
How do I transfer music from my iPod to my iPad?
I have so many wires and leads and cannot see one that connects my ipad to ipod or ipad to PC. Do I now have to buy yet ANOTHER accessory from Apple or can this be done wirelessly? Any help appreciated, thanks. :-)
-
When downloadin​g e-cards i get the audio but cannot see picture or animation.
I have tried downloading e-cards containing animation. However, I only get the audio.
-
Can't find my microsoft 2008 after upgrading to lion
can't find my microsoft 2008 after upgrading to lion
-
Donwload Test Plan does not work in GRC PC 3.0 Portal
Hello Experts, We have GRC PC 3.0 SP3 ABAP and JAVA standalone systems. Configured ADS configuration and all the ADS related checks "FP_TEST_00" and others working fine, even are able to see the print version of documents from portal. Trying to downl