scriptlet « API « JSP-Servlet Q&A





1. iterating over Enum constants in JSP    stackoverflow.com

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 ...

2. scriptless JSP    stackoverflow.com

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 ...

3. getParameter only returning part of the string    stackoverflow.com

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) ...

4. Refactoring JSP scriptlet loop to be more readable    stackoverflow.com

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 ...

5. How to avoid using scriptlets in my JSP page?    stackoverflow.com

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 ...

6. JSPX scriplet inside HTML input type textbox    stackoverflow.com

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 ...

7. Instantiating classes between jsp scriptlets    stackoverflow.com

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 ...

8. Methods in jsp scriptlet?    stackoverflow.com

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:

<%
  ...

9. What is the difference between variable declaration in the declaration section and in scriptlet in jsp?    stackoverflow.com

<%! int x=10;%>
<% int y=11; %>
What is the difference between variable declaration in the declaration section and in scriptlet in jsp?





10. Code requires try/catch in JSP declaration section but not in the scriptlet section?    stackoverflow.com

I have the following block of code that works just fine:

<%@page import="java.util.*" %>
<%@page import="java.security.*" %>

<%
String str = "A string to hash.";
MessageDigest md = MessageDigest.getInstance("MD5");
md.update( str.getBytes() );
byte[] digest = md.digest();
StringBuffer hexString = ...

11. JSP - Loads of submit buttons and loads of IF statements    stackoverflow.com

My JSP page has many Submit buttons for example

<input type="submit" name="RemoveCustomer" value="Submit"/>
<input type="submit" name="AddCustomer" value="Submit"/>
and within my scriptlet tag I have something like this
if(request.getParameter("addByName") != null && request.getParameter("addByName").length() > 0) {
 ...

12. Is this an acceptable case to use a JSP scriptlet?    stackoverflow.com

I know that using JSP scriptlets is generally frowned upon, which is why I'm wondering if there is a more elegant way of achieving what I'm trying to do. Pretty much ...

13. What is the difference between a variable using declaration and a variable is declared using Scriptlet?    stackoverflow.com

What is the difference between a variable using declaration and a variable is declared using Scriptlet?

<%!  ... %>     :  in declaration
<% ...   %> ...

14. How to use an object that is available in JSP within a scriptlet, can this be done    stackoverflow.com

I have a variable called statements which I am iterating over and naming row

<c:forEach items="${statements}" var="row">
Can I now use this variable row in a scriptlet if I do something like
<% ...

15. Displaying Java Property in JSP    stackoverflow.com

I have a class with a property called title and I have a getter/setter that gets and sets the property. If the property is P I need to print the word ...

16. How To: jsp scriptlet equivalent code in freemarker    stackoverflow.com

I am working on one POC where I need to create a freemarker ftl equivalent to a JSP. The aim is to find out how easy is to create jsp equivalent ...





17. Confusion in understanding include file in my web application    stackoverflow.com

I have a problem in understanding the below mentioned code snippet.Actually it a content on .inc file. What i am confused about is what will be stored in the path variable. will ...

18. scriptlet gets executed wrongly    stackoverflow.com

The following code:

<button type="button" id="button" onclick="<%cart.removeItem(0);%>">Click me</button>
is suppose to be executed when the button is clicked. However,
 "<%cart.removeItem(0);%>"
is being executed when page is refreshed without clicking the button. Why is ...

19. jsp scriptlet function called from button click    stackoverflow.com

I am looking for a quick and dirty way to allow a user to enter something in a text field, click a button, and have some results be displayed based on ...