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

java.lang.ClassNotFoundException this error occurs in jsp page after changes made in jsp.This kind of error occurred after update jRun4 with updater 7 using java 1.6 how to handle this error pls help.
0
Enroll in August's Course of the Month
LVL 9
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

I was reading about Resource Bundles

as below
internationalization feature of the JDK provides a mechanism for separating user interface (UI) elements and other locale-sensitive data from the application logic in a program.
I can relate with local sensitive data separation but not the UI elements like buttons etc why we need to separate?

pelase advise
0
i am using jsp page to insert some value but when the parameters get to the servelet the values received are null when I am using Post method but when Get method is used then it works fine.
request.getParameter() is returning null value when post method is used but when get method is used it works fine and the values get inserted

anyone have idea how to fix this???

//Jsp Page

<%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!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=UTF-8">
    <link rel="stylesheet" href="insert.css">
    <title>Database Update</title>
    </head>
    <body>
    <h1 class="main-header">Enter the Details</h1>
    <div class="fullbody">

    <form action="Insert" method="post" enctype="multipart/form-data">
    <div class="text">
    <b>Stuid:</b>
    <input type="text" placeholder="stuid" name="stuid" pattern=[0-9]{1,} title="can only have numeric value" required>
    <b>Student Name:</b>
    <input type="text" placeholder="student name" name="name" pattern="[A-Za-z ]{1,45}" title="can only have alphabet and space" required>
    <b>Student Mobile no.:</b>
    <input type="text" placeholder="student mobile no." name="stumob" pattern=[0-9]{10} title="10 digit number" required>
    <br>
    <b>Father's Name:</b>
    <input type="text" …
0
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
[root@web02 ~]# cat /etc/*-release
CentOS release 6.8 (Final)
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)

[root@web02 ~]# yum info -v apache-tomcat-apis
Loading "fastestmirror" plugin
Config time: 0.076
Yum Version: 3.2.29
rpmdb time: 0.000
Setting up Package Sacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.rafal.ca
 * extras: centos.mirror.rafal.ca
 * updates: ca.mirror.babylon.network
pkgsack time: 0.126
Installed Packages
Name        : apache-tomcat-apis
Arch        : noarch
Version     : 0.1
Release     : 1.el6
Size        : 246 k
Repo        : installed
From repo   : base
Committer   : Andrew Overholt <overholt@redhat.com>
Committime  : Tue Feb  2 07:00:00 2010
Buildtime   : Wed Nov 10 19:18:17 2010
Install time: Sun May 28 11:58:23 2017
Installed by: root <root>
Changed by  : System <unset>
Summary     : Tomcat Servlet and JSP APIs
URL         : http://tomcat.apache.org/
License     : ASL 2.0
Description : Apache Tomcat's Servlet 2.4/JSP 2.0 and Servlet 2.5/JSP 2.1 APIs.

[root@web01 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

[root@web01 ~]# yum info -v apache-tomcat-apis
Loading "fastestmirror" plugin
Config time: 0.009
Yum version: 3.4.3
rpmdb time: 0.000
Setting up Package Sacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.globo.tech
 * extras: centos.bhs.mirrors.ovh.net
0
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
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!

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
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
New feature and membership benefit!
LVL 9
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 wonder why and what for we use below option


eclipse preferences download repository index updates on startup


what exactly it does in .m2 folder. 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
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

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
>