scriptlet

iterating over Enum constants in JSP

Hi, I have an Enum like this package com.example; public enum CoverageEnum { COUNTRY, REGIONAL, COUNTY } I would like to iterate over these constants in JSP without using scriptlet code. I know I can do it with scriptlet code like this: <c:forEach var="type" items="<%= com.example.CoverageEnum.values() %>"> ${type}...

scriptless JSP

Hi, Is there any way to do the equivalent of the following in a JSP without using scriptlet? <% response.setContentType("text/plain"); %> I can't simply use <%@ page language="java" contentType="text/plain" %> because I need to set the content-type in 2 places (each in a different branch of a ) and the JSP compiler will only allow...

Access Get parameter with a scriptlet

I hava a url such as search.do?offset=20 offset sometimes is in the url sometimes not. When it is not in the URL i want it to be 0. i try, without success, to retrieve the value with a scriptlet as follows: <% Integer offset = (pageContext.findAttribute("offset")==null) ? new Integer("0") : new Integer((String) pageContext.findAttri...

In JSP, how to identify the type of Object present in a List ?

Is it possible in JSP to get the type of Object in List, just like we do in Java myDataBind.getResultsList().get(0).getClass(); or is it possible to achieve something like this: if ( myDataBind.getResultsList().get(0) instanceOf MyClass ) { doThis; } i don't prefer scriptlets, but if it is not possible to do without scriptlets th...

Verify Scriptlets in ASPX files compile with MSbuild

Sometimes after some refactoring occurs, and we produce a successful build, some legacy code using scriptlets fails to compile on runtime. I would like it if there was a way that I can verify that scriptlets will compile using msbuild. Is that what aspnet_compiler is for? Thanks ...

getParameter only returning part of the string

Kindly assist here, the getParameter is only printing the first portion of the String element in the tag. here is the select tag <select name="ActionSelect" id="ActionSelect" > <%Iterator itr;%> <% List data = (List) request.getAttribute("data"); for (itr = data.iterator(); itr.hasNext();) { String value = (String) itr.next();...

Refactoring JSP scriptlet loop to be more readable

I have some JSP code, which writes a tree representing hierachical data. This data is represented using nested layers. In the JSP code there are many code snippets similar to the following code (which outputs as many closing div tags as is the numerical value of variable differenceAmount): <jsp:scriptlet> int differenceAmount = pr...

How can i use JSTL variable in scriptlet?

I have to access the JSTL variable which is calculated inside the iterator. Excerpt of code: <c:forEach var="resultBean" items="${resultList}" varStatus="status"> card: ${resultBean.cardNum} </c:forEach> i would like to access ${resultBean.cardNum} in the scriptlet code. what i am doing right now is: <c:forEach var="resultBe...

How to avoid using scriptlets in my JSP page?

Hi, I've been told that the use of scriptlets (<%= ... %>) in my JSP pages isn't such a great idea. Can someone with a bit more java/jsp experience please give me some pointers as to how to change this code so its more 'best practice', whatever that may be? This JSP is actually my sitemesh main decorator page. Basically my web design h...

JSPX scriplet inside HTML input type textbox

Hi, I have the following in my jspx file: <jsp:scriplet> int myvar = 2; </jsp:scriptlet> How can I put variable myvar into a textbox (id=myinput) value using JSTL or scriptlet (I can do this using session variable) <input type="text" id="myinput" value="...the value of myvar..."/> Thanks ...

Struts2 scriptlet

Using struts2 with jsp with standard struts tag libraries. I'm trying to dynamically hide a DIV on page load, but still send it to the browser. This is so I can show it later via javascript. The request objects one and two are not easily referenced via a jsp:usebean tag. (They are enums and cannot be instantiated) I tried using a ...

Instantiating classes between jsp scriptlets

Is it possible to instantiate a class and then invoke its methods between scriptlets in JSP? I am getting errors and I don't know why (java class and methods are fine). Any other way to do the same (i just want a string from a method in a class)? ...

Is there an option for code completion in JSP scriptlets in JDeveloper?

I have a little problem with JDeveloper. It has excellent code completion abilities in java files, and it also works fine for tags in JSP files, but it doesn't work inside scriptlets. For example, if I have code like this: <x:sometag attribute=<%=MyClass.A I want it to automatically complete it, when I press Ctrl+space, with the avail...

what does dash mean in ruby on rails html scriptlet ?

In the web I've seen examples both with <% if @showIt -%> some html content <% end -%> and without <% if @showIt %> some html content <% end %> dash. Both versions work very well. So, what difference does it make? Thanks! ...

JSP outside a web container

Hello, I am starting a project that will have many "files" (like a web servers .html or jsp files). Each of these files will have "JSP" embedded in the files, for example; Hello <%="John Doe" %> I would then like to programatically send this file through a "JSP Compiler" and then get the output file. I have looked at the Tomcats...

I can pass a variable from a JSP scriptlet to JSTL but not from JSTL to a JSP scriptlet without an error

The following code causes an error: 1. <c:set var="test" value="test1"/> 2. <% 3. String resp = "abc"; 4. resp = resp + test; 5. pageContext.setAttribute("resp", resp); 6. %> 7. <c:out value="${resp}"/> The error says "error a line 4: unknown symbol 'test'". How do I pass test from the JSTL code to the JSP scriptlet? ...

Methods in jsp scriptlet?

I know its not recommended, and I should be using tag libraries etc etc. But I'd still like to know if it is legal to declare methods in a jsp scriplet: <% public String doSomething(String param) { // } String test = doSomething("test"); %> Is that legal? I am getting some weird compile errors (like a ; is expected)...

Why can I not transfer a scriptlet attribute to JSTL in this JSP custom tag?

The string: ${prettyDate} is output to the page by this custom tag instead of the prettified Date string: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ tag import="com.ocpsoft.pretty.time.PrettyTime, java.util.Date"%> <%@ attribute name="dateParam" required="true" type="java.util.Date" %> <% PrettyTime p = ne...

Unterminated string constant

My Description contains an apstrophe('). How to escape it. <a href='javascript:select("<%= pageBean.replace(list.getColumn(0), "'", "'") %>", "<%= pageBean.replace(list.getColumn(1), "'", "'") %>");' title="<%=selRpt%>"> <span class='img-view'></span></a> "<%= pageBean.replace(list.getColumn(1), "'", "'") %>" is the description part i...