Posts

Showing posts from November, 2022

Java Network Classes Part2

Image
  Java Networking Tutorial   Goto Part1   HttpURLConnection class   It is the subclass URLConnection Provides support for HTTP connctions on port 80. to open a connection we use openConnection on a URL object and must cast the result to HttpURLConnection. methods   getRequestMethod() getResponseCode() getResponseMessage() getHeaderFields()   import java.net.* ; import java.io.* ; public class HttpURLDemo { public static void main (String[] args) throws IOException { URL hp = new URL( "http://www.google.com" ); HttURLConnection hpCon = (HttpURLDemo) hp. openConnection (); System. out . println ( "Request method is" +hpCon. getRequestMethod ()); System. out . println ( "Response code is" +hpCon. getResponseCode ()); System. out . println ( "Requst method is" +hpCon. getResponseMessage ()); Map<String>,List<String> hdrMap=hpCon. getHeaderFields ()); Set<String> hdrField = hdrMap. keySet

Java Network classes Part1

Image
Java Networking Tutorial   Goto Part2 All network related classes are bundled in java.net package in Java Language. It includes various classes and interfaces for implementing networking applications. This tutorial gives you an overview of java.net package. Classes and Interfaces available in Java.net Package InetAddress Inet4Address    |   are subclasses of InetAddress    Inet6Address    |   URL URLConnection HttpURLConnection Socket,              | ServerSocket    |    These classes uses TCP, to communicate over the network. DatagramPacket,      | DatagramSocket,      |   These classes uses UDP  to communicate over the network. MulticastSocket        | Java programs can use both TCP or UDP based classes to communicate over the Internet. TCP/IP based classes Socket —Generally used by client program to communicate with the Server. A socket is one end-point         of a two-way communication link between two programs running on the network. ServerSocket → with the ServerSocket se

Java Network Programming tutorial

Image
    Java Networking Introduction  Java Networks Home         Java is practically a synonym for Internet programming. To write network based programs, Java providing a rich set of classes in a package called java.net. Network Basics   What Is a Socket?        A socket is a connection between two programs running on the network for two-way communication.  Socket classes are used to represent the connection between a client program and a server program. port → A numbered socket on a particular machine. Client connects to a port to request a particular service.       A server allows multiple clients to connect to the same port number. To accomplish this,  a server process must be  a multithreaded. Socket communication takes place via a protocol. What is protocol?     A protocol is a common set of rules that are accepted by both the ends to communication,     acceptance of data format etc. IP (Internet Protocol) → a low level routing protocol that breaks data into small packets and send

AngularJS Routing

Image
    AngularJS Navigation Tutorial     Angular provides a separate module, RouterModule to set up the navigation in the Angular application. Let us learn the how to do the routing in Angular application in this chapter. It does moves from one view (list of expenses) to another view (expense details). Let us create a new application   C:\> ng new routing-app  Angular CLI generate a new module, AppRoutingModuele for routing purpose. The code looks as follows − import { NgModule } from '@angular/core' ; import { RouterModule, Routes } from '@angular/router' ; const routes: Routes = []; @ NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] })   export class AppRoutingModule { } above code, Imports RouterModule and Routes from @angular/router package. RouterModule allows configuring and execute routing in the application. Routes is the type used to setup the navigation rules. Routes is the local variable (of type Routes) used to configu

AngularJS Form Validation

Image
    AngularJS Form Validation Tutorial     Form validation is mandatory for any web application.  To validate whether the user input is in correct format or not.     RequiredValidator & PatternValidator   1. RequiredValidator  How to use required field validation in angular. Create a component with the name formval. c:\>myapp>ng g c formval 2. PatternValidator PatternValidator is used to validate regex pattern. In the given code pattern validator used to perform email validation.  In the below code, email pattern validator added inside the Validator. Example:   open up formval.component. ts file and add the code   formval.component.ts import { Component, OnInit } from '@angular/core' ; import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms' ; import { ReactiveFormsModule } from '@angular/forms' ; @ Component({ selector: 'app-formval' , templateUrl: './formval.component.html' , styleUrls: [ &#