JSP

15K

Solutions

2

Articles & Videos

7K

Contributors

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 legacy system developed 10 years ago.

 A jsp page---SalesEditBillingAddress.jsp

<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" > 
<jsp:param name="dept" value="sales"/>
</jsp:include>    

Open in new window


second jsp page---marketingEditBillingAddress.jsp

<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" > 
<jsp:param name="dept" value="marketing"/>
</jsp:include>    

Open in new window


The reason to pass the parameter is because the generic page----edit_billing_address.jsp has different form action need to be submitted based on different parameters.

  <html:form action="/actions/${param.dept}/editBillingAddress">
<html:text name="customerBillingAddressBean" property="address1"  maxlength="60"> </html:text> 
.............
<html:text name="customerBillingAddressBean" property="contact" maxlength="60"></html:text>
<html:text name="customerBillingAddressBean" property="email" maxlength="80"></html:text>

<button type = "submit" class ="btn btn-primary">Submit</button>		   
</html:form>        

Open in new window



however, tomcat 8.0 with java 1.8 complain about this line of code:
<html:form action="/actions/${param.dept}/editBillingAddress">

Open in new window


javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /actions/${param.dept}/editBillingAddress

The example on this page:

http://beginnersbook.com/2013/12/jsp-include-with-parameter-example/

shows that my code is nothing wrong about it.

my question is: how to make the parameter work in the action URL?

I also tried the following code:

			 
			 <c:set var="myVar" value="${param.dept}" />

			 <c:if test = "${myVar eq 'sales'}">
			   <html:form action="/actions/sales/editBillingAddress">  
			 </c:if>
		    
		        <c:if test = "${myVar eq 'marketing'}">
			   <html:form action="/actions/marketing/editBillingAddress">
		         </c:if>

                ............. many input fields ...............

                        <button type = "submit" class ="btn btn-primary">Submit</button>		           
	                </html:form>        
	  

Open in new window


but it doesn't work because the eclipse compiler give error message due to only one closed form tag could be found.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
Hi,

When i right click on junit test(say ProductWeightTest.java) and run as Junit test from eclipse i keep getting popup with error

error could not create the java virtual machine error a fatal exception has occurred. program will exit



when i run individual test (checkWeightLessthan10Lb) in above test ProductWeightTest.java  i keep getting initialization error in eclipse console.

i tried changing eclise .ini entries but still getting same error. please advise
0
when i run junit test class getting initializationError Runner: Junit 4

not sure why suddenly i am getting that error and how to resolve it.

please advise
0
Hi,

I have a setter method(setBeginDate) that changed by some one from calendar date object to String object.

now i have to change my unit test to reflect that by changing to String.

articleVisibleData.setBeginDate(setDateMonthYear(30, 1, 2015));

How i edit method above so that i get String

earlier method is

            public Calendar setDateMonthYear(int day, int month, int year) {
            Calendar cal = GregorianCalendar.getInstance();
            cal.clear();
            cal.set(Calendar.DAY_OF_MONTH, day);
            cal.set(Calendar.MONTH, month);
            cal.set(Calendar.YEAR, year);
            return cal;
      }

now i am trying like below but wont work


      public String setDateMonthYear(int day, int month, int year) {
            String str="";
            str= str.concatenate(date).concatenate(month).concatenate(year)
            return str;
      }


earlier from test case i used to call like

articleVisibleData.setDate(setDateMonthYear(30, 1, 2015));

please advise
0
I am a newbie JSP & Servlets.I  am trying to  use(copy)    code of one JSP page  to another JSP page.The goal is to have the   same functionality across the two pages.But it seems I am missing  implicit objects attributes  set up in previous page.How can I have previous Implicit objects displayed in my  current page?
0
I have JSP page and drop down list programatically populated.
Now, under some circumstances that dropdown should be disabled, but user should be still able to see all of it's element, but can't actually select it, something like this: https://jsfiddle.net/nenadbulatovic/6g4pmmpv/1/

Obviously as there is condition I can't just put disable next option.

This is actual part of code (drop down) where I need that.

  <div class="row-fluid">
    <div class="span3">
      <label><%=Constants.REQUIRED%>&nbsp;<c:out value="${requestScope.RESOURCES_MAP.SITE_PARENT}"/>:</label>
        <select class="selectpicker" data-width="100px" id="siteParentNameSelect" style="width:250px;margin-bottom:0px;">
          <option value=''>${requestScope.RESOURCES_MAP[SELECT]}</option>
          <c:forEach var="siteParentName" items="${siteParentNameList}">
            <option value="${(pageContext.request, siteParentName.id)}" ${siteParentName.id == '0' ? 'selected = "selected" ' : ''}> ${siteParentName.name}</option>
          </c:forEach>
        </select>
    </div>
  </div>

Open in new window


I should check if some condition like "enabledFlag" and then if it is true/false enable/disable its elements for selection.
0

There is also helpful tutorials on BlazeMeter.com for JMeter, you don't have to use BlazeMeter but they do allow you to import your JMeter .jmx file and run tests if that is a route you want to go.

I am reading as above. I wonder what are difference between JMeter Vs BlazeMeter, advantages, disadvantages, practical uses.Please advise
0
Hi,

I am going through below link

http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html

I was not clear on DTDs and Java version relationship and which one to use in WEB.XML.

Please advise
0
Hi,

When we use batch vs regular insert in spring DAO application.
purchaseDAO.batchInsert(purchase);
please advise
0
Free Tool: ZipGrep
LVL 9
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.

Hi,
what are differences, advantages, disadvantages between

dao vs facade design patterns used i java and j2ee applications?
please advise
0
Under the facade project i have


FacadeResponse facadeResponse = new FacadeResponse();
            
            List<Report> reportNumbers = new ArrayList<Report>();
            
                  facadeResponse.setSuccess(true);
                  facadeResponse.setResponse(reportNumbers );


Report object in turn have bunch of fields like

private String reportNumber;
      
      private Calendar reportDate;



How do i set values of  so that callign web service see proper data in response.

reportNumber and reportDate within facade?

reportNumbers is not simple array list of String object where i can easily call add method.

reportDate again has Date, Time,TimeZone etc

please advise
0
Hi,

In eclipse when i expand on a project i see MAven Dependencies and target
I am trying below example
https://www.mkyong.com/spring3/spring-3-hello-world-example/
i like to know when to what is use of MAven Dependencies and target

please advise
md1.png
md2.png
0
Hi,

I am working on below spring application

https://www.mkyong.com/spring3/spring-3-hello-world-example/

My junit class shows bunch of errors LIKE

The import junit cannot be resolved

How to resolve these issues. please advise
JUNITteST.png
0
Hi,

I am trying simple spring examples like hello world


I see maven not picking latest jars like spring core (4.1.6)instead picking old jar(3.0.5) from .m2.

How to tell maven to take latest but not old jar. I wonder why it is taking old jars. Please advise
mavenjars.png
mavenjars2.png
mavenjars3.png
mavenjars4.png
mavenjars5.png
0
hi,

while importing as existing maven project i see some projects have single pom.xml some other projects have top level pom and also sub level pom.xml as well. why we need like parent pom and child pom kind of structure for some projects?
please advise
0
Hi,

I am trying below example
http://www.mkyong.com/spring3/spring-3-hello-world-example/

when i do mvn clean install from comand prompt getting below error

spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)


when i do internally from STS(like eclipse) editor maven clean is happening fine. While doing maven install getting below errors

COMPILATION ERROR :
[INFO] -------------------------------------------------------------
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-core\4.3.3.RELEASE\spring-core-4.3.3.RELEASE.jar; invalid LOC header (bad signature)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[3,35] package org.springframework.context does not exist
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[4,43] package org.springframework.context.support does not exist
how to resolve

my code is

pom.xml is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	

Open in new window

0
Hi,

I started my glassfish server.

I went to below url
http://localhost:4848/common/index.jsf
gives error like

This site can’t be reached

localhost refused to connect.
Search Google for localhost 4848 common index

how to know exact port number where server is running and admin console exact url.

please advise
0
Hi,

In eclipse i have TestWeb project with bunch of jsp and html files in eclipse. I right clicked on it and copied. Then i pasted then eclipse asked name TestWeb2 ok? i said yes. I created TestWeb2. Now when i try to run TestWeb 2 tomcat9 complains

Could not publish server configuration for Tomcat v9.0 Server at localhost.
Multiple Contexts have a path of "/TestWeb".

how to change the context name or path so that i can run TestWeb2 project as well in tomcat ?
please advise
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,

I am workign in jsp CRUD operations 0n mysql with and without prepared statements and hibernate approach. I wonder what are advanges and disadvantages and practical uses of each approach? can you please provide some sample code on each aproach to try on mysql databse preferable with primary key and foeign key kind of relationships as i am not that strong on the data modeling and relationships?
please advise
0
Hi,

My jso application giving below error


username:admin123
username:admin1
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','01091999','tt','t@t.com','AAA')' at line 1
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)


How to resolve this.
my account.jsp is
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Account Creation Screen</title>
</head>
<body>
	<%@include file="header.jsp" %>
	<div style="width: 300px; margin-left:auto;margin-right:auto;">
		
		<h1>Account Creation Screen</h1>
		<form action="accountCreate.jsp">
			<table>
				<tr>
					<td>			
					Name
					</td>
					<td>
					<input type="text" name="name"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					DOB
					</td>
					<td>
					<input type="text" name="dob" placeholder="Sample Format 1989-01-31"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					Address
					</td>
					<td>
					<textarea type="textarea" name="address" rows=10 style="width:200px; height:100px;"></textarea><br>
					

Open in new window

0
Hi,

how to run on tomcat not jboss eap wild fly7.0. Wnhen i run the web application index.jsp it is by default starting jboss wild fly server not tomcat 8.0 . how when run as server particular jsp run tomcat8 all the time. pleas advise
0
 

 
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
 
public class MyHashMapEntrySet3 {
 
    public static void main(String arg[]){
      HashMap hm = new HashMap<Integer, String>();
    	//HashMap hm = new TreeMap<String, String>();
    	//HashMap hm = new LinkedHashMap<String, String>();
        //add key-value pair to hashmap
        hm.put(3, "C");
        hm.put(1, "A");
        hm.put(2, "B");
        //hm.put(3, "C");
        System.out.println(hm);
        //getting value for the given key from hashmap
       /* Set<Entry<String, String>> entires = hm.entrySet();
        for(Entry<String,String> ent:entires){
            System.out.println(ent.getKey()+" ==> "+ent.getValue());*/
       //d }
    }
}

Open in new window


{1=A, 2=B, 3=C}


i wonder how i got above sorted output based on key all the time first 1 then 2 then 3 key set? please advise
0
i have tried  to return a Boolean to the method  isEdit()  but with no  success......can anyone please point me to the right direction? The IDE give me error saying can not return a value from method with void type,i don't see any void in my method..i have returned Boolean.

// create an empty array list with an initial capacity
	List<Integer> companyID = new ArrayList<Integer>(4);
	companyID.add(254162);
	companyID.add(272836);
	companyID.add(285582);
	companyID.add(279944);

	public boolean isEdit(){

		if (companyID.contains(company.getId()) ) {

			return acl.hasPermission("Companies Edit");
		} else {
			return false;
		}
	}

Open in new window

0
Hi,

I have a html to logn and then jsp to insert to mysql databse.

i am getting errors like below

java.sql.SQLException: Incorrect date value: 'null' for column 'dob' at row 1

java.sql.SQLException: Column 'userid' not found.

java.sql.SQLException: Unknown column 'typeofaccout' in 'field list'

java.sql.SQLException: Column 'userid' not found.


how to effectively debug and resolve these kind of jsp and html related issues.

can i put debug point in jsp page and html page like regular java file and start application in debug mode?
please advise.
0

JSP

15K

Solutions

2

Articles & Videos

7K

Contributors

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
>