Questions tagged [scriptlet]

A Scriptlet is a piece of raw Java code embedded in a JSP file which gets executed in line with the JSP output.

A Scriptlet is a piece of raw Java code embedded in a JSP file which get executed in line with the JSP output (which is usually HTML). It's recognizeable by the Java code between the <% and %> tags. Its use is since JSP 2.0 (2003) as per the JSP coding conventions discouraged in favor of tag libraries like JSTL and expression language EL to control the flow of JSP output. The real business job such as preprocessing (e.g. loading data from DB) and postprocessing (e.g. saving submitted form) should be done in a servlet.

Scriptlets are these days considered old school and a bad practice. They are however still useful for quick prototyping and testing, for example to quickly prepare/stub values in top of JSP so that JSTL tags and EL expressions further down in the JSP page can quickly be prototyped/tested.

411 questions
9
votes
2 answers

How to display a variable value in JSP file

I want to display the value of variable named "id" in my code. The code is - index.html(line 5)-
But whenever i am executing it, it is throwing error An error occurred at line: 5 in…
Neha Gupta
  • 987
  • 5
  • 16
  • 35
9
votes
3 answers

rpm scriptlet ordering for install/remove/upgrade using yum

I'm working on a bug in our rpm scriptlets which is probably originating from order in which our scriptlets are executed during package install/removal/upgrade. We are using yum on Redhat Enterprise. Obviously I first need a good understanding of…
fgysin
  • 11,329
  • 13
  • 61
  • 94
7
votes
2 answers

how to print values in console using scriplet in javascript while a function is called

How to print values in console (like System.out.println() in java) using scriplet in javascript while a function is called ? if i used System.out.println("test") in scriplet the values is getting printed while a jsp form is loading but i want it to…
7
votes
1 answer

Use EL ${XY} directly in scriptlet <% XY %>

In my project I've to assign a variable every time the JSP is being opened. I tried it with scriptlets <% %> in JSP and EL ${} which gives the variable back. But it seems not working. <% String korrekteAntwort=${frage.korrekteAntwort};%> …
pythoniosIV
  • 237
  • 5
  • 18
7
votes
3 answers

JSP - what's the difference between “<% … %>” VS “<%= … %>”

While working with JSP files and servlets , I came across <% … %> and <%= … %> . What's the difference between both cases ? Thanks
JAN
  • 21,236
  • 66
  • 181
  • 318
6
votes
2 answers

How to pass java variables from scriptlets to c:when expression in jstl?

what is a proper way to use variables from scriptlets in jstl? I don't know what is wrong in my code: <% boolean a = true; boolean b = false; %>
Peters_
  • 597
  • 2
  • 8
  • 28
6
votes
2 answers

%post scriptlet failed.. Where is this scriptlet located?

I have an error: %post(blabla.i386) scriptlet failed, exit status 1 Where is located this scriptlet?
vir2al
  • 817
  • 4
  • 11
  • 15
6
votes
4 answers

JSP and scriptlets

I know that using scriptlets are considered taboo nowadays. Its okay and I will agree to the Top Star's words (as I am just a novice in Java at the moment). What I have heard so far is, its to make the designers life easier. But I wonder, if it has…
M-D
  • 10,247
  • 9
  • 32
  • 35
6
votes
4 answers

Scriptlet in JSP - Accessing request objects

I know its best to use jstl in JSPS but I have been explicitly told to use scriptlets in this project.My question is that my servlet attached an item of Arraylist to the request object and i wanted to loop over that item using scriptlet. Example :…
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
5
votes
1 answer

convert from scriptlet to JSF managed bean problem

I am trying to convert this scriptlet code to JSF class. The view code and the java code private HtmlForm form = new…
mvg
  • 1,574
  • 4
  • 37
  • 63
5
votes
2 answers

How to call java constant variables from jsp expression language in Spring?

I've spent a day looking for the right solution, but no luck! The question is that how to call java constant variables from jsp with el ${bean.objectName} for example. What is the best practice? I wonder if this is doable, im quite new to Spring and…
Adrianus Hendry
  • 143
  • 2
  • 9
5
votes
2 answers

Can I put java code inside the .jrxml (jasperreport)?

Can I put java code inside the .jrxml? For example, I want to put an if() or a "new ..()" Is it possible? How? Thanks
user297339
4
votes
1 answer

textbox value to scriptlet

">
joanna
  • 117
  • 1
  • 4
  • 12
4
votes
1 answer

How do I access in a <%= scriptlet %>

I started following one tutorial about JSTL tags. The repositories tutorial used are too old, so I wanted to try it my way using some newer versions. Unfortunately, I am stuck now. I will tell you what I did, so I hope, you can help me out. I…
Stefan
  • 969
  • 6
  • 9
4
votes
3 answers

Calling method onClick of Jsp form Jsp

I wish to call a method in JSP onClick, the method is on the same JSP inside scriptlet. How should I archive this? <%@ page import="java.io.*,java.lang.*,java.util.*,java.net.*,java.util.*,java.text.*"%> <%@ page…
Abhishek Patil
  • 1,373
  • 3
  • 30
  • 62
1
2
3
27 28