Struts2 Tiles implementation with internationalization with input from database - database

I am a newbiee to Struts2 tiles. I want to write website having multiple pages and having support for multiple languages. Many pages will have same layout (so using tiles) only login page will have different layout.
I have searched in for reading the language specific Data from Database and have a method ready for it. I have the base layout ready but I am not able to understand how to integrate internationalization and tiles.
Attaching base layout and Database method
DBResourceBundle.java
package com.ruukki.webui.util;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import com.ruukki.webui.vo.ConnectionType;
import com.ruukki.webui.vo.User;
public class DbResourceBundle extends ResourceBundle
{
private Properties properties;
public DbResourceBundle(Properties inProperties)
{
properties = inProperties;
}
#Override
#SuppressWarnings(value = { "unchecked" })
public Enumeration<String> getKeys()
{
return properties != null ? ((Enumeration<String>) properties.propertyNames()) : null;
}
#Override
protected Object handleGetObject(String key)
{
return properties.getProperty(key);
}
public static ResourceBundle.Control getMyControl()
{
return new ResourceBundle.Control()
{
#Override
public List<String> getFormats(String baseName)
{
if (baseName == null)
{
throw new NullPointerException();
}
return Arrays.asList("db");
}
#Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException,
InstantiationException, IOException
{
if ((baseName == null) || (locale == null) || (format == null) || (loader == null))
throw new NullPointerException();
ResourceBundle bundle = null;
if (format.equals("db"))
{
Properties p = new Properties();
Connection con = null;
Statement s = null;
ResultSet rs = null;
try
{
con = LocalDbManager.getConnectionForUser(new User("sa","")) ;
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM Language_Text");
int value =3;
if (locale != null)
{
System.out.println("locale has vlue " + locale.getLanguage());
if(locale.getLanguage().equals("en")){
value = 3;
}else if(locale.getLanguage().equals("fi")){
value = 4;
}
}
s = con.createStatement();
System.out.println("stmt:" + s);
rs = s.executeQuery(query.toString());
System.out.println("Executed Query and got data:" + query);
System.out.println("Column count" );
while (rs.next())
{
p.setProperty(rs.getString(1), rs.getString(value));
}
System.out.println("Is property Filleked" + p.isEmpty());
}
catch (Exception e)
{
System.out.println("failed to build properties file");
e.printStackTrace();
throw new RuntimeException("Can not build properties: " + e);
}
finally
{
ConnectionManager.closeQuietly(con, s, rs);
}
bundle = new DbResourceBundle(p);
}
return bundle;
}
#Override
public long getTimeToLive(String baseName, Locale locale)
{
return 1000 * 60 * 30;
}
#Override
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
{
return true;
}
};
}
}
tiles.xml
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="baseLayout" template="/baseLayout.jsp">
<put-attribute name="title" value="Template"/>
<put-attribute name="header" value="/header.jsp"/>
<put-attribute name="menu" value="/menu.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
<put-attribute name="footer" value="/footer.jsp"/>
</definition>
</tiles-definitions>
header.jsp
<%# page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags" %>
<head>
<link type="text/css" rel="stylesheet" href="ruukki.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="header">
<table width="100%">
<tr>
<td width="10%"><div id="Logo" > <img src="logo.png"> </div></td>
<td width="50%"><div id="Welcome_Portal"> Welcome to Portal !!! </div>
<td width="15%"><p align="left" style="vertical-align: bottom;">Welcome, <s:property value="username"/></p></td>
<td width="2%" align="center"><img alt="" src="Image/flag_en.png"></a></td>
<td width="2%" align="center"><img alt="" src="Image/flag_fin.png"></td>
<td width="2%" align="center"><img alt="" src="Image/flag_sw.png"></td>
<td width="5%"><s:url id="logout" action="logout"/>
<s:a href="%{logout}" target="_parent">Logout </s:a>
</td>
</tr>
</table>
</div>
</body>
strtus.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="*Link" method="{1}" class="com.tutorials4u.actions.LinkAction">
<result name="welcome" type="tiles">welcome</result>
<result name="struts" type="tiles">struts</result>
</action>
</package>
</struts>
baseLayout.jsp
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!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">
<title><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
<table border="0" cellpadding="2" cellspacing="2" align="center" width="100%" height="100%">
<tr>
<td height="10%" colspan="2">
<tiles:insertAttribute name="header" />
</td>
</tr>
<tr>
<td width="20%" height="80%">
<tiles:insertAttribute name="menu" />
</td>
<td width="80%" height="80%" style="min-height: 120px">
<tiles:insertAttribute name="body" />
</td>
</tr>
<tr>
<td height="10%" colspan="2">
<tiles:insertAttribute name="footer" />
</td>
</tr>
</table>
</body>
</html>
With change in language I want to display the Contents from header as per the language selected.
Currently tried with this in the page to have the language contents
<%
ResourceBundle lbls = null;
ResourceBundle msgs = null;
try {
String value = Globals.LOCALE_KEY.toString();
System.out.println("value: " + value);
Locale locale = new Locale("fi","");
lbls = ResourceBundle.getBundle("AwesomeBundle", locale, DbResourceBundle.getMyControl());
} catch (Exception ex) {
}
%>
But I want it to be used in all pages...So a bit confused. And Sorry if it is too stupied question.

Related

Unexpected End of Expression when used with #Html.Raw(Model)

I am trying to use AngularJs with ASP.NET MVC - this is my first attempt.
Index.html
#model string
#{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container" ng-init="courses = [{'name':'first'},{'name':'second'},{'name':'third'}]">
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="course in courses">
<td>{{ course.name }}</td>
</tr>
</tbody>
</table>
_Layout.cshtml
<!DOCTYPE html>
<html ng-app>
<head>
<meta name="viewport" content="width=device-width" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<script src="~/Scripts/angular.min.js"></script>
<title></title>
</head>
<body>
#RenderBody()
</body>
</html>
Above works fine and grid is displayed with Name as header and first, second and third as 3 rows. So my next step is to use
courses = #Html.Raw(Json.Encode(Model))
instead of
courses = [{'name':'first'},{'name':'second'},{'name':'third'}]
CourseController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace AngularJsMvc.Controllers
{
public class CoursesController : Controller
{
// GET: Courses
public ActionResult Index()
{
return View("Index", "", "[{'name':'first'},{'name':'second'}, {'name':'third'}]"); //This works fine when used with #Html.Raw(Model) in index.html
//return View("Index", "", GetCourses()); //This doesn't work when used with with #Html.Raw(Model) in index.html
}
public string GetCourses()
{
var courses = new[]
{
new Course { Name = "First" },
new Course { Name = "Second" },
new Course { Name = "Third" }
};
var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
return JsonConvert.SerializeObject(courses, Formatting.None, settings);
}
}
public class Course
{
public string Name { get; set; }
}
}
This works fine if I use
return View("Index", "", "[{'name':'first'},{'name':'second'},{'name':'third'}]");
But if I use
return View("Index", "", GetCourses());
Then, below is the error I get. Please help - I have been struggling for almost entire day yesterday. I tried with or without Json.Encode
angular.min.js:123 Error: [$parse:ueoe]
http://errors.angularjs.org/1.6.4/$parse/ueoe?p0=courses%20%3D
at angular.min.js:6
"<div class="container" ng-init="courses = " [{\"name\":\"first\"},{\"name\":\"second\"},{\"name\":\"third\"}]""="">"
The following worked for me:
<div class="container" ng-init="courses = #Newtonsoft.Json.JsonConvert.DeserializeObject(Model)">
This also works:
<div class="container" ng-init="courses = #HttpUtility.HtmlDecode(Model)">
It's all about how angular treats the object it tries to parse and since you're passing an HTML decoded string it will treat as a string and therefore it won't be able to iterate threw it.

What is wrong in the following angularjs code

What is wrong in my code? it is not working properly
My .html page looks like
I am a beginner level coder and have below codes:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="ISO-8859-1">
<title>Index</title>
<script type="text/javascript" src="/scripts/angular.js"></script>
<script type="text/javascript">
alert("in script");
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope , $http) {
refreshData();
function refreshData(){
alert("function called");
$http({
alert("get all countries");
method: 'GET',
url:'http://localhost:8081/SpringWithAngularJs/rest/countries.json'
}).success(function(data)
{
$scope.posts = data;
});
}
$scope.form = {
countryName : "pp",
population : "1000"
};
$scope.add=function(){
$http({
alert("add countries");
method: 'POST',
url:'http://localhost:8081/SpringWithAngularJs/rest/countries/create/'+$scope.form.countryName+'/'+$scope.form.population
}).success(function(data){
alert("Country Added");
refreshData();
});
}
$scope.remove=function(data){
$http({
alert("delete countries");
method: 'DELETE',
url:'http://localhost:8081/SpringWithAngularJs/rest/countries/delete/'+data
}).success(function(data){
alert('Country Deleted');
refreshData();
});
}
});
</script>
</head>
<body ng-controller="myCtrl">
<h1>Country List</h1>
<table border="">
<thead>
<tr>
<th>Country Id</th>
<th>Country Name</th>
<th>Country Population</th>
<th>Action</th>
</tr>
</thead>
<tr ng-repeat="c in posts">
<td>{{c.countryId}}</td>
<td>{{c.countryName}}</td>
<td>{{c.population}}</td>
<td><button ng-click="remove{$index}">Remove</button></td>
</tr>
</table>
<h1>Add Country</h1>
<table>
<tr>
<td>Country Name:</td>
<td><input type="text" ng-model="form.countryName"/></td>
</tr>
<tr>
<td>Country Population:</td>
<td><input type="text" ng-model="form.population"/></td>
</tr>
<tr>
<td><button type="submit" ng-click="add()">Add</button></td>
</tr>
</table>
</body>
</html>
my controller looks like:
When running the html page not even alert functions of javascript is working.
why this is happening?
package com.cg.springwithangularjs.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.cg.springwithangularjs.dtos.Country;
import com.cg.springwithangularjs.exceptions.CountryException;
import com.cg.springwithangularjs.services.CountryService;
#RestController
public class CountryFrontController {
#Autowired
CountryService countryService;
#RequestMapping(value="/countries",method=RequestMethod.GET,headers="Accept=application/json")
public List<Country> getallCountries(Model model){
System.out.println("in function");
try {
return countryService.getAllCountries();
} catch (CountryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
#RequestMapping(value="/countries/create/{name}/{popu}",method=RequestMethod.POST,headers="Accept=application/json")
public List<Country> addCountry(#PathVariable String name , #PathVariable String popu){
Country country = new Country();
country.setCountryName(name);
country.setPopulation(popu);
try {
countryService.addCountry(country);
return countryService.getAllCountries();
} catch (CountryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
#RequestMapping(value="/countries/delete/{id}",method=RequestMethod.DELETE,headers="Accept=application/json")
public List<Country> deleteCountry(#PathVariable String id){
try {
countryService.delete(id);
return countryService.getAllCountries();
} catch (CountryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
Remove the alert() from the configuration object in your three $http services, so that they look like
$http({method: 'GET', url: '/someUrl'}).success ...
Also try and change the remove function call from:
<td><button ng-click="remove{$index}">Remove</button></td>
to:
<td><button ng-click="remove($index)">Remove</button></td>

Binding Viewbag Data to Angular JS

I have a List in my controller which is being of type Student(class in the model)
public class DefaultController : Controller
{
// GET: Default
public ActionResult Index()
{
List<Student> obj = new List<Student>() {
new Student() { ID=1,Name="titi",Address="bbsr"},
new Student() { ID=1,Name="titi1",Address="bbsr"},
new Student() { ID=1,Name="titi2",Address="bbsr"}
};
ViewBag.data = obj;
return View();
}
}
I am using Angular JS (Beginner to Angular JS)
<html>
<head>
<title>Index</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body ng-app="EFView">
#{ var a = ViewBag.data;}
<div ng-init="init(#Html.Raw(a)">
<table>
<tr ng-repeat="x in a">
<td >
{{x.ID}}
</td>
<td>
{{x.Name}}
</td>
<td>
{{x.Address}}
</td>
</tr>
</table>
</div>
</body>
</html>
Not getting the output as expected.. where & what I am missing, I tried with all trial

How to create sample demo in gwt with angularjs using JSNI?

I have created a sample demo application which has following html page.
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype is not supported. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script>
function alert1(p1) {
alert("P1 is "+p1);
}
</script>
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="Sample_JS.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript" language="javascript" src="sample_js/sample_js.nocache.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', [])
app.controller('MyController', function ($scope, $window) {
$scope.nameList = [];
$scope.ShowAlert = function () {
$scope.nameList.push($scope.nameFieldContainer);
$window.alert("Hello Angular : "+$scope.nameFieldContainer);
}
});
</script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<div ng-app="MyApp" ng-controller="MyController">
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td data-ng-model="nameFieldContainer" id="nameFieldContainer"></td>
<td id="test" ></td>
<td id="sendButtonContainer" ng-click="ShowAlert()"></td>
</tr>
<tr>
<td> <input type ="text" data-ng-model="nameFieldContainer"> </td>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
<tr>
<td><input type = "button" name="click" ng-click="ShowAlert()"></td>
</tr>
</table>
<table align="center">
<tr ng-repeat = "name in nameList">
<td colspan="2" style="font-weight:bold;">{{name}}</td>
</tr>
</table>
</div>
</body>
</html>
My gwt controller class as below
package com.google.client;
import com.google.shared.FieldVerifier;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Sample_JS implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network "
+ "connection and try again.";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button sendButton = new Button("Add");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();
// We can add style names to widgets
sendButton.addStyleName("sendButton");
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);
// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
nameField.selectAll();
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
sendButton.setEnabled(true);
sendButton.setFocus(true);
}
});
// Create a handler for the sendButton and nameField
class MyHandler implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
//sendNameToServer();
MyTestJS.hasPopupBlocker(nameField.getValue());
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
}
// Add a handler to send the name to the server
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);
nameField.addKeyUpHandler(handler);
}
}
I am trying to call anularjs function from below native js method by using gwt button component, but i can't.
package com.google.client;
public class MyTestJS {
public static native boolean hasPopupBlocker(String name)/*-{
if (!name){
name = "Please enter name";
}else{
name = "Hello "+ name ;
}
return $wnd.ShowAlert();
}-*/;
}
How can I called angularJs ShowAlert() function from gwt (by clicking on button from java code or by other way) ?
please suggest.
any help will be appreciable......
thanks in advance.

Servlet Cannot edit record from database

I have a servlet that should update a record from my database.
There must be something wrong with my code because tomcat shows error: java.lang.NumberFormatException: null #package_ergasia.EditProtein.doPost(EditProtein.java:36) which is this line: int i = Integer.parseInt(request.getParameter("i"));
Here is my Servlet:
package package_ergasia;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class EditProtein extends HttpServlet
{
Connection connection;
Statement statement;
ResultSet resultset;
#Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
Connection connection= null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "ergasia";
String user = "root";
String password = "password";
String id = request.getParameter("id");
String name = request.getParameter("pname");
String desc = request.getParameter("desc");
String seq = request.getParameter("seq");
int i = Integer.parseInt(request.getParameter("i"));
try {
connection = DriverManager.getConnection(url + dbName, user, password);
PreparedStatement ps = connection.prepareStatement("UPDATE protein SET pdb_id=?,proteinName=?,description=?,proteinSequence=? WHERE i=?");
ps.setString(1, id);
ps.setString(2, name);
ps.setString(3, desc);
ps.setString(4, seq);
ps.setInt(5, i);
ps.executeUpdate();
RequestDispatcher view = request.getRequestDispatcher("/InsertProtein");
view.forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Here is the jsp with the form where the user can update the data:
<%#page import="java.util.Iterator"%>
<%#page import="java.util.ArrayList"%>
<%# page language="java" import="java.sql.*"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../CSS/mystyle.css">
</head>
<body>
<h1>Welcome</h1>
<form method="post" action="/EditProtein">
<fieldset style="width: 100px">
<legend>Update protein table</legend>
<table border="1">
<%
int count = 0;
if (session.getAttribute("EditData") != null) {
ArrayList al1 = (ArrayList) session.getAttribute("EditData");
Iterator itr = al1.iterator();
while (itr.hasNext()) {
count++;
ArrayList pList = (ArrayList) itr.next();
%>
<tr>
<td>pdb_id</td>
<td><input type="text" disabled="disabled" font="Verdana" name="id" value="<%=pList.get(0)%>"</td>
</tr>
<tr>
<td>Protein Name</td>
<td><input type="text" font="Verdana" name="pname" value="<%=pList.get(1)%>"</td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" font="Verdana" name="desc" value="<%=pList.get(2)%>"</td>
</tr>
<tr>
<td>Sequence</td>
<td><input type="text" font="Verdana" name="seq" value="<%=pList.get(3)%>"</td>
</tr>
<tr>
<td>i</td>
<td><input type="number" disabled="disabled" font="Verdana" name="i" value="<%=pList.get(4)%>"</td>
</tr>
<tr>
<td><input type="submit" value="Update"></td>
<td><input type="reset" value="Reset"></td>
</tr>
<% }} %>
</table>
</fieldset>
</form>
</body>
</html>
I'd appreciate your help!
here possible error line is
int i = Integer.parseInt(request.getParameter("i"));
request.getParameter("i") is not properly set on your previous page.
in this servlet parameter value is get as null,or other then number(like i76 - i is not number).
check your previous page there i is set.
Check if the parameter i is sent. Becaus if it is not set, request.getParameter("i") will return null, and when you try to convert it to an int you get the error

Resources