Improve company productivity with a Business Account.Sign Up

x

JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a jsp page using struts tag as below:
<html:form action="/actions/graphics/job/attachFile/confirm">
<html:cancel value="Cancel" styleClass="buttons"></html:cancel>
<html:submit value="Confirm"/>
</html:form>

Open in new window

     
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		ActionForward actionForward = SessionChecking.checkUserBean(mapping, request);
		if (actionForward != null)
			return actionForward;

		if (isCancelled(request))
		{
                 //do something here
                }
               //......
     }//execute

Open in new window

it works very well in production for years, now I am trying to change the looking of the button by integrating with bootstrap.
When I only changed the looking of button confirm, it looks like this:
confirm_button_only.pngat this moment, both buttons are functioning.

however, when I tried to change the looking of both buttons, it looks like this:
confirm_cancel_both.png
             <html:form action="/actions/graphics/job/attachFile/confirm">
		<button type="submit" id="cancel" name="cancel" class="btn btn-default" value="Cancel"  > Cancel</button>
		<button type = "submit" id="submit" class ="btn btn-primary" value="Confirm"> Confirm</button>
		</html:form>		

Open in new window

they both looks good, but the problem is both buttons are doing the same job, which means they both have the CONFIRM function , no more CANCEL function.

then I tried a little modification for experiment:
             <html:form action="/actions/graphics/job/attachFile/confirm">
		<button type="button" id="cancel" name="cancel" class="btn btn-default" value="Cancel"  > Cancel</button>
		<button type = "submit" id="submit" class ="btn btn-primary" value="Confirm"> Confirm</button>
		</html:form>	

Open in new window

the problem for this code is the CANCEL button does NOT work at all regardless how many time I click on it.

can anybody help me on this? all I want is just make the CANCEL button looks as big as the CONFIRM button but keep the original functioning.
I think the real question would be : how to transfer the value of CANCEL button to the HttpServletRequest such that the function isCancelled(request) can return true?
by name="cancel" ?  value="Cancel" ? or type="cancel"?
0
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I am dealing with datasource in a jsp page and getting

 javax.servlet.jsp.JspException: 'dataSource' is null

what to do in case I am not having exposure to Datasource. I can't attach the code as it is confidential.
0
I am trying to convert some coldfusion code to jsp and there are some tags like cfargument,cf:loop,cf:return,cf:location.. can anybody tell me what to use in place of these tags in jsp?
0
Hi, I've a Struts 1.x web Application and we have new enhancement we need to redirect to some other application for authenticating and  authorization. In detail, we need to remove our app login page and need to redirect to some other website for login page. I'm using response.sendRedirect(https://xxx.com) and its redirecting to other website but before we display our home page we need to validate their response by calling two times their website. My question is how can I get their website response paramers to validate. Please help us. Thanks!
0
Hi,

I want help on getting data from sql server to Java/JSP page.  I am new to Java/jsp, and need some help with some sample code.

I have a stored proc. [getemployee] which is retrieving FirstName,LastName,EmailAddress. I need to use this stored proc on Java/jsp to show details on jsp page.

Thank you so much for help!
0
I am using jsp tag library based on com.jenkov.prizetag . how can I make it keyboard accessible
0
If i have a rest controller in spring boot how can I validate the contract that comes in if certain values of the parameters need to have certain values??? ANy code examples are appreciated!
0
What is the best technology to create a new shopping website? Like JSP, bootstrap, aspx, angular, PHP etc…
0
I had this question after viewing Retain the value of Drop down box in jsp.
I tried the below code but i'm getting error : alloc_Type is undefined on refresh.
<%
 String riskTypeValue = request.getParameter("riskType");
if(riskTypeValue == null)riskTypeValue = "0";

String allocTypeValue = request.getParameter("allocType");
if(allocTypeValue == null)allocTypeValue = "0";
%>

<script>
function retainValue(){
      //alert("retainValue "+alloc_Type +" && " +risk_Type);
    var element1 = document.forms[0].allocType;
    for(x = 0; x < element1.length; x++){
            if(element1.options[x].value == "<%=alloc_Type%>")
            {
                  element1.options[x].selected = true;
                  break;
            }
    }
    var element2 = document.forms[0].riskType;
    for(x = 0; x < element2.length; x++){
            if(element2.options[x].value == "<%=risk_Type%>"){
                  element2.options[x].selected = true;
                  break;
            }
    }
}
</script>


<tr>
                        <td>&nbsp;</td>
                        <td class="smalltext" width="150px"><b>Allocation Type:</b></td>
                        <td class="smalltext">
                               <select id="allocType"
                                          class="filter_smalltext" name="allocType">
                                    <c:forEach items="${dataBO.alloc_types}" var="allocTypes">
                                          <option value="${allocTypes.key}" ${ allocTypes.key eq dataBO.alloc_type ? …
0
I have a jsp page which contain drop downs and two buttons. One button for Upload and other is Run button. I want to retain the value of drop downs even after the Upload is clicked and submitted the form so that the same values should pass for Run button . I used the below code.

<select name="riskType" class="filter_smalltext" onchange="regAuthChange();">
                                          <!-- <option value=0>Select...</option>
                                          <option value="CR">CR</option>
                                          <option value="MR">MR</option>
                                          <option value="BOTH">Both</option> -->
                                          <option value="" selected="selected">Choose One</option>
                                          <option value="<%if(request.getParameter("riskType").equals("CR")) {out.println('selected="selected"'); } %>">CR</option>
                                          <option value="<%if(request.getParameter("riskType").equals("MR")) {out.println('selected="selected"'); } %>">MR</option>
                                          <option value="<%if(request.getParameter("riskType").equals("BOTH")) {out.println('selected="selected"'); } %>">BOTH</option>
                              </select></td>



But i am getting this error :
jv_allocation_process.jsp:16:18: Error in "jv_allocation_process.jsp" at line 401: Invalid character constant
<%@ include file="templates/jv_allocation_process.jsp" %>
                 ^-----------------------------------^

        at weblogic.servlet.jsp.JavelinxJSPStub.reportCompilationErrorIfNeccessary(JavelinxJSPStub.java:247)
        at weblogic.servlet.jsp.JavelinxJSPStub.compilePage0(JavelinxJSPStub.java:183)
        at …
0
Free Tool: ZipGrep
LVL 12
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tomcat 6 TLS1.2 enabled but still using SSL2 when opening an HTTP connection

Greetings, newbie here, so I might need help formatting the question properly.

I have a application running under Tomcat 6 that needs to run TLSv1.2.
I have install the JAVA runtime edition 6.0.181 which supports TLSv1.2.
I have configured the server.xml file to use TLSv1.2 with connections to clients and wireshark shows TLSv1.2 connections to the client when they are loading pages. But one of the pages makes an API call by opening a HttpURLConnection which also needs to use TLSv1.2 and I am unable to make that work. Wireshark shows that outgoing API call as SSLv2 and the Tomcat log show an "Connection reset" error.


This is the server.xml connector that comes so close.

<Connector
                                protocol=”org.apache.coyote.http11.Http11AprProtocol”
                                port=”443” maxThreads=”200”
                                scheme=”https” secure=”true” SSLEnabled=”true”
                                SSLCertificateFile=”C:\somefolder\cert2017.crt
                                SSLCertificateKeyFile=”C:\somefolder\cert.pem”
                                SSLVerifyClient=”optional” sslEnabledProtocols=”TLSv1.2”/>


Here is the httpconnection code that needs to use tlsv1.2 to work:


String url = " https://www.tlsv12testsite/process.do ";  

            String agent = "Mozilla/4.0";
            String type = "application/x-www-form-urlencoded";
 …
0
I'm calculating values (based on input from one JSP) in a method in my Controller class and trying to pass it to another different JSP page using ModelAndView but I'm getting a weird `NumberFormatException` that I think refers to the value at line 249 from error below, ` 249:    <c:out value="${housepricesList.housePrice}"/>`:
    java.lang.NumberFormatException: For input string: "housePrice"

Open in new window

as well as another exception:
    2018-03-19 12:39:14.439 ERROR 2452 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [An exception occurred processing JSP page /houseprice.jsp at line 249

    246:     
    247: 
    248: <c:forEach items="${housepricesList}" var="HousePrice">     
    249:    <c:out value="${housepricesList.housePrice}"/>
    250:    <c:out value="${housepricesList.number_of_houses}"/>
    251: </c:forEach>
    252: 

Open in new window

I'm getting a latitude and longitude from one JSP page, passing it to a method in my Controller where I use the lat & long values to query a database to return house prices within a 1km radius of initial latitude and longitude. I want to pass this returned information (`housePrice` and `number_of_houses`) to another JSP page. However the page won't load and the errors above are displayed in the console.

Controller Class
    	@RequestMapping(value = "/parseHousePrice", method = RequestMethod.POST)
	public 

Open in new window

0
i'm trying to reload user privileges dynamically.

i'm trying to achieve custom authorization mechanism via MethodSecurityExpressionOperations or GrantedAuthority to secure the URL and authorize the URL based on the conditions.

i come across two flavours of Spring to handle this one is via MethodSecurityExpressionOperations and the other is via GrantedAuthority - createAuthorityList

i am not sure which one is better and which one to be used in the case of dynamic reloading of user privileges where one user privilege has been updated by another user dynamically while the user is working on...

Thanks.
0
Difference between Servlet Filter vs Spring Security Filter ?

Some says security filter just authenticates the user, where as servlet filter authorizes the request

Need code snippet to understand the structure of both and the differences.
0
Spring Boot Version: 2.0
Spring Version: 5.0.4

Facing the following issues on trying to implement AccessDecisionManager

1. When used

public class WebConfig implements WebMvcConfigurer

Issue:  uanble to override protected void configure(HttpSecurity http) throws Exception {

2. When used

public class WebConfig extends WebSecurityConfigurerAdapter {

Issue: unable to override the following

a. public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
b. public void addResourceHandlers(ResourceHandlerRegistry registry) {
c. public void addInterceptors(InterceptorRegistry registry) {

3. Throws error "java.lang.IllegalStateException: No ServletContext set" when used as below

public class WebConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {

URL for reference:  http://www.baeldung.com/spring-security-custom-voter

@Bean
public AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
      = Arrays.asList(
        new WebExpressionVoter(),
        new RoleVoter(),
        new AuthenticatedVoter(),
        new MinuteBasedVoter());
    return new UnanimousBased(decisionVoters);
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
    ...
    .anyRequest()
    .authenticated()
    .accessDecisionManager(accessDecisionManager());
}
0
RequestHandlerInterceptor or AccessDecisionVoter which gets called first

I'm working on spring boot application and would like to know RequestHandlerInterceptor or AccessDecisionVoter which gets invoked first
0
Where i can download a sample or demo application which has the following..Any link would be useful

1. Source code
2. Sample SQL file to populate the data in mysql table or json to populate NoSQL
3. Uses Ajax in the front-end to send and receive responses
0
I'd like to create a web page (using jsp) with a touch-screen table that can accept graphical input, like a signature or doodle. I'm cluless as to what's needed or where to start. Advice?
0
Are these same in Drools  ?

code -1 :

when
    $city : City()  
   
then
    //Do something
end

Open in new window



code -2 :

when
    city : City()  
   
then
    //Do something
end

Open in new window


Note ..they are differed by "$" only.

I have seen two such versions  in Drool like above............sometimes  we use  "$"  and sometimes  without "$"  . Do they mean same thing  ?
0
Free Tool: Path Explorer
LVL 12
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I have a function, referenced by numerous other programs, whose parameters are not able to be changed:

static void reportDetail(Statement stmt, BufferedWriter outFile, String detailColumn) throws Exception

However, the body of the function is defined locally in any given program. What I need to do in one particular program is reference a string defined in the main program, e.g.:

String localVar = globalVar;

where globalVar is defined outside the scope of reportDetail().

Is there a way to do this? (this is jsp BTW)
0
We have a JSP web app (runs on Tomcat on Windows) that needs to do file read/writes.  We want to distribute the web servers, but need a central file server so we know we're going to introduce latency as it reads/writes to the shared folder (\\server\folder type sharing via SMB).

Is there some sort of document or any good articles on the latency ceiling for this?  I expects it's not a hard limit, but just that at some point the latency/bandwidth leads to the process taking longer and hence more web server resources will be consumed (from the users making the requests that lead to this read/write).  Probably mainly memory for the threads/code running while they're running.  What I'm trying to find is anything about failures.  For instance if reading a 50 k file is making calls and there's 1000 ms or 2000 ms or etc. what's the effect of that.  Is there a point (3000 ms latency) or other things of that sort at which point the read/write will generate errors (in other words timeouts and such).
0
I am struggling with a problem on JSF Primefaces 6.0 where in I have main page which has the list of addresses and main save button. The list of addresses in displayed in data table and the user can click on the edit button to edit any row of the data table. The edit button opens a dialog popup where user can change the address attributes and the click on "OK" button which should updated the list grid data as well as updated the address object in the listgrid of the main bean.
Currently I am facing the problem where my changes in the address popup are not visible in the backing bean method.


Sample code :-

<main:form>
      <addresslistTable> bean:addressList
            <addressline1> value="variable.addressline1" onclick--> bean.getAddressById(variable.id)
      </addresslistTable>
</main:form>

<addressDialog:form>
      <addressline1> value="bean.otherAddress.addressline1"  --> user can change this value
      <p:commandButton value="#{msg.common_save}" process="@this" action="#{bean.submit}" update=":main:addresslistTable" oncomplete="PF('addressDialog').hide()"/>
</addressDialog:form>




class bean {
Address otherAddress;


public getAddressById(addressId){
      otherAddress = getAddressFromDatabaseById(addressId);
}


public void submit(){
// here I am accesing the otherAddress.addressLine1 which is still showing be the old value

}

}
samplecode.txt
0
How to create a BaseDAO class for jdbcTemplate which handles the save, update and delete in generic way so that we can use the same in any entity.

for example, in sales we may have the id column as salesId, in product we have the id column as id, in inventory table we will have the id column as invId.

Assume we need to have one generic method for save which gets something like parameter names and values and inserts it

Example as

https://stackoverflow.com/questions/23830961/jdbctemplate-utilities-for-insert-statement

However the above example doesn't clearly says the or gives the implementation of the BaseObjectMapper and seems pretty big

Need a proper way to define the save, update and delete.
0
I have hyperlink in a jsp page that calls a javascript (<a href="javascript:somefunction()" > Save </a> )

someFunction() is in same jsp, but the function body contains methods from another.js file.

In Mozilla ESR onblur and onclick event is executing simultaneously.

But, in Chrome and IE it is working fine.

Can someone please help on this ?
0
how to check domain name availability in javascript using jsp
0

JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.

Top Experts In
JSP
<
Monthly
>